title: attach image_field to entity in drupal 7
body: <p>I use drupal 7, and Entity API to develope a module.  I have an entity to record client information.  I wish to use image_field to let client upload their logo.  So I have this function:</p>
  
  <pre><code>    function silver_client_enable()
  {
    field_cache_clear();
    field_associate_fields("silver_client");
  
    if(field_info_field('logo'))
      return;
  
    $field = array(
      'field_name' =&gt; 'logo',
      'cadinality' =&gt; 1,
      'type' =&gt; 'image',
      );
  
      field_create_field($field);
  
    $instance = array(
      'field_name' =&gt; 'logo',
      'entity_type' =&gt; 'silver_client',
      'bundle' =&gt; 'silver_client',
      'label' =&gt; 'Logo',
      'description' =&gt; 'Logo',
      'display' =&gt; array(
        'default' =&gt; array('label' =&gt; 'hidden')
      ),
      'settings' =&gt; array(
        'file_directory' =&gt; '/logo',
      ),
      'widget' =&gt; array(
        'type' =&gt; 'image_image',
       ),
    );
  
    field_create_instance($instance);
  }
  </code></pre>
  
  <p>In the entity creation/edit form, I use :</p>
  
  <pre><code>field_attach_form('silver_client', $client, $form, $form_state);
  </code></pre>
  
  <p>to attch the field.  </p>
  
  <p>When I called up this form, the image upload field was corrected displayed.  An i can use it to uplod file to serve.  </p>
  
  <p>In the form submit function, I save the entity as:</p>
  
  <pre><code>entity_save('silver_client', $client);
  </code></pre>
  
  <p>However, after I press the save button, the entity table is correctly saved.  Field table is not.  Both field_data_logo and field_revision_logo are empty.  </p>
  
  <p>I believer Entity API looks after the retrieving and saving of attached fields.  Can someone tell me what is wrong with my code?  Thank you. </p>