Problem/Motivation
The inline form errors are getting repeated on child elements. The repeated error messages are shown only if an error is set on the whole form element.

Steps to reproduce
1. Enable "inline_form_errors" and "block_content" core modules.
2. Enable the "inline_entity_form" contrib module.
3. Create a block type, add a text field.
4. To any node type, add an entity_reference field.
- Type of item to reference: "content_block".
- Reference type >> block type: select block type from step #3.
5. For the entity_reference field, use "Inline entity form - simple" widget on the managed form display page.
6. Trigger $form_state->setErrorByName on the entity_reference field.
7. You will find the form error message repeating for each inline form field.
Proposed resolution
The form error message should not be repeated for child elements.
| Comment | File | Size | Author |
|---|---|---|---|
| Screenshot 2024-05-28 at 6.43.59 PM.png | 238.5 KB | gaurav_manerkar |
Issue fork drupal-3450375
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gaurav_manerkar commentedComment #3
cilefen commentedIs this a duplicate of #2880011: Add a #disable_inline_form_errors_summary property to disable the Inline Form Errors summary?
Comment #4
gaurav_manerkar commented@cilefen No, its not a duplicate.
Disabling inline form errors is not a solution, but an alternative. Its definitely not a good approach.
The proper solution is to prevent the repeating of error messages on child elements from parent.
Comment #5
gaurav_manerkar commentedIssue root cause is described in https://www.drupal.org/project/drupal/issues/2509268#comment-10058436
Comment #6
cilefen commentedok
Comment #8
gaurav_manerkar commentedComment #9
gaurav_manerkar commentedComment #10
cilefen commentedWe shouldn't add the "Accessibility" tag unless this needs specific review from that team. Perhaps it does. Yet this seems an ordinary bug.
I've removed other tags according to https://www.drupal.org/node/3156530.
Comment #11
smustgrave commentedLeft some comments
Tagging for sub-maintainer and usability as that may be by design. Following the steps you're adding a single reference field. If there are any errors in the form that field failed as a whole.
But will say think #2880011: Add a #disable_inline_form_errors_summary property to disable the Inline Form Errors summary would be worth pushing along.