From 4493da352cc369b5448cbb47465a509ba8cbd997 Mon Sep 17 00:00:00 2001
From: Trevor Simonton <trevor@westernascent.com>
Date: Thu, 8 Nov 2012 14:36:19 -0700
Subject: [PATCH] Issue #1835852 by tmsimont: Changed the ief_id to use an imploded parents array when constructing a unique identifier to allow multiple fields of the same instance in one form

---
 inline_entity_form.module |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/inline_entity_form.module b/inline_entity_form.module
index 9723604..cb48ca8 100644
--- a/inline_entity_form.module
+++ b/inline_entity_form.module
@@ -316,7 +316,7 @@ function inline_entity_form_field_widget_form(&$form, &$form_state, $field, $ins
   $parents = array_merge($element['#field_parents'], array($element['#field_name'], $element['#language']));
 
   // Assign a unique identifier to each IEF widget.
-  $ief_id = $instance['id'];
+  $ief_id = strtr(implode("-",$parents), array(' ' => '-', '_' => '-', '[' => '-', ']' => '')).'-'.$instance['id'];
   // Determine the wrapper ID for the entire element.
   $wrapper = 'inline-entity-form-' . $ief_id;
   $element = array(
@@ -1093,7 +1093,7 @@ function inline_entity_form_field_attach_submit($parent_entity_type, $parent_ent
     if (isset($instance['widget']) && $instance['widget']['type'] == 'inline_entity_form') {
       $field_name = $instance['field_name'];
       $langcode = $form[$field_name]['#language'];
-      $ief_id = $instance['id'];
+      $ief_id = $form[$field_name][$langcode]['#ief_id'];
       // There's no IEF data for this field, skip it.
       if (empty($form_state['inline_entity_form'][$ief_id])) {
         continue;
-- 
1.7.4.msysgit.0

