commit 4f62df5a781917929d4f2eda04c3535c2b66267b
Author: Mickey Williamson <mickey@micnap.com>
Date:   Mon Jul 29 17:13:05 2013 -0400

    inline entity form for contacts

diff --git a/modules/redhen_contact/lib/redhen_contact.inline_entity_form.inc b/modules/redhen_contact/lib/redhen_contact.inline_entity_form.inc
new file mode 100644
index 0000000..c73d798
--- /dev/null
+++ b/modules/redhen_contact/lib/redhen_contact.inline_entity_form.inc
@@ -0,0 +1,95 @@
+<?php
+
+/**
+ * @file
+ * Defines the inline entity form controller for Nodes.
+ */
+
+class RedHenContactInlineEntityFormController extends EntityInlineEntityFormController {
+
+  /**
+  * Overrides EntityInlineEntityFormController::labels().
+   */
+  public function labels() {
+    $labels = array(
+      'singular' => t('contact'),
+      'plural' => t('contacts'),
+    );
+    return $labels;
+  }
+
+  /**
+   * Overrides EntityInlineEntityFormController::entityForm().
+   */
+  public function entityForm($entity_form, &$form_state) {
+    $contact = $entity_form['#entity'];    
+
+    // Do some prep work on the contact, similarly to node_form().
+    if (!isset($contact->first_name)) {
+      $contact->first_name = NULL;
+    }
+    if (!isset($contact->last_name)) {
+      $contact->last_name = NULL;
+    }
+    
+    $entity_form['name'] = array();
+    $entity_form['name']['first_name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('First name'),
+      '#default_value' => $contact->first_name,
+      '#maxlength' => 255,
+      '#required' => TRUE,
+      '#weight' => -6,
+    );
+    $entity_form['name']['middle_name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Middle name'),
+      '#default_value' => $contact->middle_name,
+      '#maxlength' => 255,
+      '#weight' => -6,
+    );
+    $entity_form['name']['last_name'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Last name'),
+      '#default_value' => $contact->last_name,
+      '#maxlength' => 255,
+      '#required' => TRUE,
+      '#weight' => 5,
+    );
+    
+    field_attach_form('redhen_contact', $contact, $entity_form, $form_state);
+
+    return $entity_form;
+  }
+
+  /**
+   * Overrides EntityInlineEntityFormController::entityFormSubmit().
+   */
+  public function entityFormSubmit(&$entity_form, &$form_state) {
+      parent::entityFormSubmit($entity_form, $form_state);
+
+      //module_load_include('inc', 'redhen_contact', 'includes/redhen_contact.forms');
+      
+      //dpm($entity_form);
+      //dpm($form_state);
+      
+      //$contact = &$form_state['redhen_contact'];
+      $contact = &$entity_form['#entity'];
+      
+      // Save default parameters back into the $contact object.
+      $contact->first_name = $contact->name['first_name'];
+      $contact->last_name = $contact->name['last_name'];
+      
+      // Set the contact's author uid
+      global $user;
+      $contact->author_uid = $user->uid;
+      
+      // get form_state array, only including the subform of this entity
+      $child_form_state = form_state_defaults();
+      $child_form_state['values'] = drupal_array_get_nested_value($form_state['values'], $entity_form['#parents']);
+      
+
+      // Save the contact.
+      $contact = redhen_contact_save($contact);
+  }
+}
diff --git a/modules/redhen_contact/redhen_contact.info b/modules/redhen_contact/redhen_contact.info
index 518b681..540a818 100644
--- a/modules/redhen_contact/redhen_contact.info
+++ b/modules/redhen_contact/redhen_contact.info
@@ -11,6 +11,7 @@ files[] = lib/redhen_contact.controller.inc
 files[] = lib/redhen_contact.entity.inc
 files[] = lib/redhen_contact.metadata.inc
 files[] = lib/redhen_contact.views.inc
+files[] = lib/redhen_contact.inline_entity_form.inc
 files[] = lib/redhen_contact_type.controller.inc
 files[] = lib/redhen_contact_type.entity.inc
 files[] = lib/redhen_contact_type.ui_controller.inc
diff --git a/modules/redhen_contact/redhen_contact.module b/modules/redhen_contact/redhen_contact.module
index 1240dce..ea9a0c0 100644
--- a/modules/redhen_contact/redhen_contact.module
+++ b/modules/redhen_contact/redhen_contact.module
@@ -25,6 +25,9 @@ function redhen_contact_entity_info() {
       'metadata controller class' => 'RedhenContactMetadataController',
       'entity class' => 'RedhenContact',
       'views controller class' => 'RedhenContactViewsController',
+      'inline entity form' => array(
+        'controller' => 'RedHenContactInlineEntityFormController',
+      ),
       'base table' => 'redhen_contact',
       'revision table' => 'redhen_contact_revision',
       'fieldable' => TRUE,
