Problem/Motivation

When the inline form errors module is enabled and a name field is completely empty, the resulting error messages are overly generic and messages are shown for hidden components. Here is what it looks like:

Screenshot of name field with inline validation

It would be great if just the required, visible components received error messages. It would also be great if those messages were contextual to the component in error.

Steps to reproduce

  1. Create a fresh D10 install.
  2. Composer require and enable the dev branch of the name module.
  3. Enable the inline form errors module.
  4. Create an entity with a name field or add a name form element to any form. Make sure at least one component is required.
  5. Submit the empty form.

In case it helps, here is a module that illustrates the scenario: https://www.drupal.org/files/issues/2023-11-10/inline_name_validation_te...

Proposed resolution

Update the name_element_validate function in name.module to provide a different validation strategy when inline form errors is enabled.

Issue fork name-3400886

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

lkacenja created an issue. See original summary.

lkacenja’s picture

StatusFileSize
new35.96 KB

I opened an MR that I believe fixes the problem. Here is what it looks like on that branch.

A screenshot of the name module with improved inline form errors

greggles’s picture

Status: Active » Needs review

Thanks for filing this issue and MR, @lkacenjar. Moving to Needs Review status since there's a proposed fix in an MR that needs feedback from the maintainers.

rymcveigh’s picture

Status: Needs review » Reviewed & tested by the community

The current changes in this MR have been working for us for the last 11 months. These changes are ready IMO.

heddn made their first commit to this issue’s fork.

  • heddn committed 9185392f on 8.x-1.x authored by lkacenja
    Issue #3400886 by lkacenja, rymcveigh, heddn: Inline Form Validation...
heddn’s picture

Status: Reviewed & tested by the community » Fixed

Thxs for the contributions.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.