Possible to create fields without admin? Possible Duplicate:
  Assign Fields programatically to custom node defined by custom module  




Is it possible to create fields in code without using admin in Drupal 7?
Yes. Since fieldable things in D7 are called "bundles", you essentially 1. create the field and 2. attach it to the bundle that uses it (could be a content type, etc.) I wrote this function to quickly create and attach fields in my module's .install file:

function _add_field_to_bundle($field_name, $cardinality, $type, $label, $entity_type, $bundle, $field_settings=array(), $instance_settings=array()) {

  $new_field = array(
    'field_name' =&gt; $field_name,
    'cardinality' =&gt; $cardinality,
    'type' =&gt; $type,
    'settings' =&gt; $field_settings,
  );
  field_create_field($new_field);


  $field_instance = array(
    'field_name' =&gt; $field_name,
    'label' =&gt; $label,
    'entity_type' =&gt; $entity_type,
    'bundle' =&gt; $bundle,
    'settings' =&gt; $instance_settings,
  );

  field_create_instance($field_instance);
}


To use this function to attach a thumbnail image field to a (node) content type:

_add_field_to_bundle('field_thumbnail', 1, 'image', 'Thumbnail', 'node', 'content_type');