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.

Issue with form messages

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.

Issue fork drupal-3450375

Command icon 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

gaurav_manerkar created an issue. See original summary.

gaurav_manerkar’s picture

Issue summary: View changes
cilefen’s picture

Component: forms system » inline_form_errors.module
Status: Active » Postponed (maintainer needs more info)
Issue tags: -inline form errors, -user experience
gaurav_manerkar’s picture

Status: Postponed (maintainer needs more info) » Active

@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.

gaurav_manerkar’s picture

cilefen’s picture

ok

gaurav_manerkar’s picture

Component: inline_form_errors.module » forms system
Issue tags: +i
gaurav_manerkar’s picture

cilefen’s picture

Status: Active » Needs review
Issue tags: -Accessibility, -inline form errors, -inline entity form

We 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.

smustgrave’s picture

Left 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.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.