Create a textfield and an instance


  $field = array(
    'field_name' => 'demo_textfield',
    'type' => 'text',    
  );
  
  field_create_field($field);
  
  $instance = array(
    'field_name' => 'demo_textfield',
    'entity_type' => 'node',
    'bundle' => 'article',
    'label' => t('Demo texfield'),
    'description' => t('Just a demo textfield'),
    'widget' => array(
      'type' => 'text_textfield',
    ),
  );

  field_create_instance($instance);

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.