title: Correct way to use Drupal 7 Entities and Field API
body: <p>I'm trying to use Drupal 7's entities and field API to correctly build a new module. What I have been unable to understand from the documentation is the correct way to use the new API to create a 'content type' (not a node type) with a number of set fields, such as Body.</p>
  
  <p>I'm trying to set up the entity using hook_entity_info, then I believe I need to add the body field using field_create_instance, but I can't seem to get it to work.</p>
  
  <p>In mycontenttype.module:</p>
  
  <pre><code>/**
   * Implements hook_entity_info().
   */
  function mycontenttype_entity_info() {
    $return = array(
      'mycontenttype' =&gt; array(
        'label' =&gt; t('My Content Type'),
        'controller class' =&gt; 'MyContentTypeEntityController',
        'base table' =&gt; 'content_type',
        'uri callback' =&gt; 'content_type_uri',
        'entity keys' =&gt; array(
          'id' =&gt; 'cid',
          'label' =&gt; 'title',
        ),
        'bundles' =&gt; array(
          'mycontenttype' =&gt; array(
            'label' =&gt; 'My Content Type',
            'admin' =&gt; array(
              'path' =&gt; 'admin/contenttype',
              'access arguments' =&gt; array('administer contenttype'),
            ),
          ),
        ),
        'fieldable' =&gt; true,
      ),
    );
    return $return;
  }
  
  /**
   * Implements hook_field_extra_fields().
   */
  function mycontenttype_field_extra_fields() {
    $return['mycontenttype']['mycontenttype'] = array(
      'form' =&gt; array(
        'body' =&gt; array(
          'label' =&gt; 'Body',
          'description' =&gt; t('Body content'),
          'weight' =&gt; 0,
        ),
      ),
    );
    return $return;
  } 
  </code></pre>
  
  <p>Then does this go in the .install file?</p>
  
  <pre><code>function mycontenttype_install() {
    $field = array(
      'field_name' =&gt; 'body',
      'type' =&gt; 'text_with_summary',
      'entity_types' =&gt; array('survey'),
      'translatable' =&gt; TRUE,
    );
    field_create_field($field);
  
    $instance = array(
      'entity_type' =&gt; 'mycontenttype',
      'field_name' =&gt; 'body',
      'bundle' =&gt; 'mycontenttype',
      'label' =&gt; 'Body',
      'widget_type' =&gt; 'text_textarea_with_summary',
      'settings' =&gt; array('display_summary' =&gt; TRUE),
      'display' =&gt; array(
        'default' =&gt; array(
          'label' =&gt; 'hidden',
          'type' =&gt; 'text_default',
        ),
        'teaser' =&gt; array(
          'label' =&gt; 'hidden',
          'type' =&gt; 'text_summary_or_trimmed',
        ),
      ),
    );
    field_create_instance($instance);
  }
  </code></pre>