Problem/Motivation
Field Group Complete currently determines group completeness based on whether required fields contain values. This can result in a group being marked complete even when Drupal has rendered validation errors for fields within that group after a failed submission. Additionally, once validation error markup is present, the group may remain in an error state even after the user edits the field to correct the issue, until the next submission occurs.
This behavior can be confusing for editors and does not accurately reflect the current state of the form as the user interacts with it.
Steps to reproduce
- Enable Field Group Complete.
- Add Field Group tabs to a form and include a required field with server-side validation (for example, a required Link field).
- Add
novalidateto the form viahook_form_FORM_ID_alter()so browser validation does not block submission. - Enter an invalid value and submit the form, causing Drupal to render validation error markup.
- Observe that the field group is still marked complete.
- Edit the errored field and observe that the group remains marked incomplete despite user input.
Proposed resolution
Update Field Group Complete to detect validation error indicators present in rendered form markup (such as error classes or aria-invalid attributes) and treat affected groups as incomplete.
Additionally, when a user edits a field that currently has validation error markup, treat those error indicators as stale and re-evaluate group completeness based on current field values. This ensures that groups reflect the user’s in-progress corrections without requiring a full revalidation cycle.
Remaining tasks
- Finalize JavaScript logic for detecting validation error indicators in rendered markup.
- Track user edits to fields so stale error indicators can be ignored.
- Add FunctionalJavascript test coverage for validation error handling and error clearing on field edits.
User interface changes
Field groups containing validation errors will not be marked complete. When the user edits an errored field, the group’s error state will clear and completeness will be recalculated based on current values.
Issue fork field_group_complete-3563687
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 #4
jcandan commented