entity_translation_prepare_element() currently clones the $form_state array and passes it to field_attach_form(). field_attach_form() will proxy to many other hooks within the system, some of whom alter the form_state for their later use. All of this is attached to the clone entity_translation_prepare_element() creates, but the $form_state is passed by reference to entity_translation_prepare_element() meaning Drupal intends to get whatever changes were made to form_state there back out for the rest of the system.
Inline Entity Form and perhaps other modules (paragraphs?, field_collection?) do EXACTLY this. IEF in particular adds settings to the form_state for later use during its submit. These values are missing as the code currently stands and cause a cascade of errors that ultimately result in a db error. Simply NOT cloning the $form_state and passing it as normal to field_attach_form() seems to solve this. Obviously some testing is probably in order, but I wanted to get more eyeballs on this, so please, take a look.
Eclipse
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 2651050-2.patch | 677 bytes | eclipsegc |
Comments
Comment #2
eclipsegc commentedCODE!
Comment #3
joelpittetNice find, going to give this a try(in production where else;). If only form_state was an object:P Oh wait, d8
Comment #4
heathdutton commentedGoing to try this as well. Nice!
Comment #5
plachIt's been a while since I wrote that code, but IIRC the idea was exactly to isolate the original form state to avoid unexpected side effects. However, I don't remember having encountered specific issues, it was kind of a precaution. OTOH I'm seeing the value of using the original form state instead, since nested entity forms are clearly a legit use case for that. My only concern is still that performing this change may introduce some unexpected and hard to track down side effect, however the OP is compelling, so I think we should try this.
Comment #6
plachI will try to tag a new release soon, I've been promising that for quite a while now, once I've done that we can commit this and start experimenting with it.
Comment #7
loopduplicate commentedI left a related comment in https://www.drupal.org/node/1344672?page=1#comment-10883654 . Basically, the patch from this issue doesn't help. Instead, I use the patch from https://www.drupal.org/node/2339315#comment-10848466 .