When you have more than a single required inline entity form on the page, if you submit one of the inline entity forms, the second form is also submitted. The "Add Node" button seems to be taking the entire contents of the form and submitting it to /system/ajax.

Here's an example of the POST data I made on an example request:

field_organizers[und][form][field_salutation][und]:Ms.
field_organizers[und][form][title]:Llama
field_organizers[und][form][field_affiliation][und][0][value]:Mc
field_organizers[und][form][field_email][und][0][value]:test@gmail.com
field_organizers[und][form][field_phone][und][0][value]:4052213312
field_name_of_committee[und][0][value]:
body[und][0][value]:
body[und][0][format]:filtered_html
field_panel_presenters[und][form][title]:
field_panel_presenters[und][form][field_salutation][und]:_none
field_panel_presenters[und][form][field_presenter_name][und][0][value]:
field_panel_presenters[und][form][field_affiliation][und][0][value]:
field_panel_presenters[und][form][field_length_of_presentation][und][0][value]:
field_panel_presenters[und][form][body][und][0][value]:
field_panel_presenters[und][form][body][und][0][format]:filtered_html
field_panel_presenters[und][form][field_bibliography][und][0][value]:

field_organizers and field_panel_presenters are both required inline entity forms. I'd guess it would just need to unset the field_panel_presenters section.

Comments

bojanz’s picture

Category: bug » support
Status: Active » Fixed

That is how Drupal's AJAX API works. The complete form is always submitted, but the non-relevant parts are discarded (so the first IEF form only gets its own data, etc).

cthos’s picture

But they aren't discarded evidently.

I've attached some screenshots. The first is the entity form that is at the top of the page after I have submitted one entity to it.

The second screenshot is after I add an entity to the second form. Note that there is a blank entity above the populated entity. That first entity is a blank node in the database, and it skipped all validation.

The other two screenshots are the expanded forms.

cthos’s picture

Status: Fixed » Active
cthos’s picture

StatusFileSize
new716 bytes

Well, I've got this narrowed down. The inline_entity_form_process_entity_form is being called as many times as there are entity forms on the page. The #ief_id is different for each call (as would be expected), but that method doesn't actually ever check to ensure that the triggering_element matches up to the #ief_id that it is attempting to operate on.

I've attached a pretty hacky patch. It isn't by any means fool proof, since the edit flow tacks on the position to the end of the element's name, which could conflict with the ief_id if it happens to be a low number.

Hopefully someone who is more familiar with IEF than I can point me to a better solution, but I didn't see much in the way to go on from the $form_state.

bojanz’s picture

Status: Active » Closed (duplicate)