eca_form: Ajax using limited validation errors leads to faulty reads of submission values

Issue information

From user: mxh

Related to !346 (merged) !342 (merged)

Contribution record

Fork management

Problem/Motivation

We're building some complex multistep forms, using Ajax with actions like "Form: add Ajax handler" and we read values using either "Entity form: build entity" as well as "Form field: compare submitted value" to dynamically enable or disable further fields in an entity form.

There is a problem, when fields are dynamically hidden or shown, that themselves contain Ajax logic. One example is the file field, that uses Ajax when uploading a file to the form.

The problematic part is, that the Ajax form may have '#limit_validation_errors' specified. When that's the case, then Drupal's form building process will only include the specified (or even none) values into the values array of the form state (getting via $form_state->getValues()). This circumstance is not yet covered by ECA's form components, and may lead to faulty situations, when the submitted values need to be read out, but are (wrongly) not returned.

Steps to reproduce

Attaching two exported examples, one is using "Entity form: build entity" and another one is using "Form field: compare submitted value" instead (can be tested on a fresh standard installation profile). The models are using some Ajax functionality, finally showing a file field for uploading contents.

When trying this out, one could also stumble accross the fact that a file will be silently removed when the file field is being hidden again. But that's actually a different issue, which is an old but still present core bug: #1205822: File(s) silently deleted when #access=false

Proposed resolution

Make ECA's form components more resilient against the described circumstance.

This needs a backport to 1.1.x, but it could be that the provided MR cannot get merged into 1.1.x (due to code differences between the two). If you need help for the backport, just let me know.

Remaining tasks

User interface changes

API changes

Data model changes

Edited by drupalbot
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information