IEF mutates/cleans form state of embedding form in unexpected manner

Created on 7 August 2025, 3 months ago

Problem/Motivation

The call to $form_state->cleanValues() when submitting the embedded form ( https://git.drupalcode.org/project/inline_entity_form/-/blob/45bc6296271... ) can break expectations in the embedding form; for example: ctools wizards expect to be able to make use of the 'op' to control its flow ( https://git.drupalcode.org/project/ctools/-/blob/5a323c6e5072515148a54b4... ) however if a step embeds an inline entity form, the $form_state->cleanValues() call presently clears out the 'op' before the wizard makes use of it, and so the wizard is unable to proceed.

Steps to reproduce

Embed an inline entity form.
In your submit handler, see the 'op' missing from your form state (as well as the couple of other values, form ID, build ID and token).

Proposed resolution

Some combination of:

  1. Create, clean, and use a copy of the form state in IEF's submission to avoid mutating the original form state.
  2. Allow for submission to proceed with original form state without calling `cleanValues()`. Could be an additional boolean toggle property for the render element, defaulting to cleaning, but allowing it to be skipped? Or, instead of boolean, introduce a third state which deals with a clone of form state?
  3. Remove the call to cleanValues

Most straight-forward would be to just remove the call. According to the docs: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21Fo...

This function can be used when a module wants to store all submitted form values, for example, by serializing them into a single database column.

Given we are not directly serializing the array of values ourselves, but instead allowing the form mode/display to extract and set values on the entity being built and calling any #entity_builders callbacks, calling ::cleanValues() does not seem appropriate in IEF's submission flow.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇨🇦Canada adam-vessey PE, Canada

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024