I am trying to set up Entityforms and IEF modules to work together, but I'm quite a beginner and struggling on this. Am I supposed to modify Entityform.module and:

1. Create a class EntityformInlineController that extends EntityInlineEntityFormController?
2. add "inline entity form' => array(
'controller' => 'EntityFormInlineController',

somewhere in the file? (not sure where though, should it be in the function entityform_entity_info()?).

Am I missing anything else?

Thanks a bunch!


bojanz’s picture

Yes, your assumptions are correct.

philipz’s picture

I'm trying to implement this based on node and commerce product examples. I'm trying to make it work with Inline entity form - Single value widget. So far I've managed to add the controller and I see the form displaying correctly. The problem is it's not saving entityform. I've tried adding entityFormSubmit and save functions to my IEF controller but they are ignored (I've tried dpm inside of them). As I understand those two are not required anyway?

Any guidance will be greatly appriciated!
The controller looks like this.

class EntityformInlineEntityFormController extends EntityInlineEntityFormController {

  * Overrides EntityInlineEntityFormController::labels().
  public function labels() {
    $labels = array(
      'singular' => t('enitityform'),
      'plural' => t('enitityforms'),
    return $labels;

   * Overrides EntityInlineEntityFormController::entityForm().
  public function entityForm($entity_form, &$form_state) {
    $entityform = $entity_form['#entity'];
    field_attach_form('entityform', $entityform, $entity_form, $form_state);
    return $entity_form;
   * Overrides EntityInlineEntityFormController::entityFormSubmit().
  public function entityFormSubmit(&$entity_form, &$form_state) {
    parent::entityFormSubmit($entity_form, $form_state);

    $entityform = & $entity_form['#entity'];

    // 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.
    $entityform = entityform_save($entityform);

   * Overrides EntityInlineEntityFormController::save().
   * Saves entityform.
  public function save($entity, $context) {
philipz’s picture

OK after some testing I understand that inline_entity_form is trying to attach submit actions to $form but entityform in submit mode is a strange kind of form.

The inline_entity_form_field_widget_form function show that for entityform submission page it sees $form as

... (Array, 2 elements)
#parents (Array, 0 elements)
#entity (Object) Entityform
  uid (NULL)
  type (String, 6 characters ) serwis
  entityform_id (String, 0 characters )
  is_new (Boolean) TRUE
  title (String, 0 characters )
  created (String, 0 characters )
  changed (String, 0 characters )
  data (String, 0 characters )

I got different result trying to do this ECK style and the entity got saved with empty fields and parent entity was not saved at all.

$entity_form = array_merge($entity_form, entityform_edit_form($entity_form, $form_state, $entity_form['#entity']));

philipz’s picture

OK I failed to mention clearly that I'm trying to make this work putting entityform IEF inside another entityform. I'll make sure this works inside node first.

bojanz’s picture

IEF does this:

function inline_entity_form_form_alter(&$form, &$form_state, $form_id) {
  if (!empty($form_state['inline_entity_form'])) {
    // Mark the parent form submit button with a special flag that will trigger
    // a save of inline forms and entity weights.
    if (!empty($form['submit'])) {
      $form['submit']['#ief_submit_all'] = TRUE;
    elseif (!empty($form['actions']['submit'])) {
      $form['actions']['submit']['#ief_submit_all'] = TRUE;

I believe you just need to set #ief_submit_all on the correct submit element.
bojanz’s picture

Issue summary:View changes
Status:Active» Postponed (maintainer needs more info)

Waiting for a response.

philipz’s picture

Yes I've found this part that sets #ief_submit_all on the submit element and I understand it. However the problem here might be with Entityforms module itself and how it adds submit or just with both modules weights and racing.

The dpm($form_state) just before the part you pasted in #5 shows there's no $form['submit'] yet (as in #3). Is it possible that Entityforms adds submit element later after IEF inline_entity_form_form_alter function runs? If so then what could be done?
Thank you for interest! I must have missed the notification e-mail of your reply.

bojanz’s picture

Status:Postponed (maintainer needs more info)» Fixed

Sorry, didn't see this. Let us know what you ended up doing.

Status:Fixed» Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.