RSS
 

ревизии

warning: Creating default object from empty value in /usr/local/www/jail4/kostya.in.ua/public_html/modules/taxonomy/taxonomy.pages.inc on line 34.

Создание поля программно

Создаем программно поле-список:

$field_name = 'field_foo';
$field = field_info_field($field_name);
if (empty($field)) {
  $field = array(
    'field_name' => $field_name,
    'type' => 'list_text',
    'settings' => array(
      'allowed_values' => array(
        'a' => t('A'),
        'b' => t('B'),
        'c' => t('C'),
        'd' => t('D'),
      ),
    ),
  );
  field_create_field($field);
}
 
$instance = array(
  'field_name' => $field['field_name'],
  'entity_type' => 'node',
  'bundle' => 'foo',
  'label' => t('Foo'),
  'widget'=> array(