Form conditional validation prevents creating content model document

Created on 7 April 2023, over 1 year ago
Updated 22 April 2023, over 1 year ago

Problem/Motivation

When attempting to create a content model document for nodes, clicking save doesn't do anything and there is an error in the dev tools console: An invalid form control with name='name[0][value]' is not focusable..

The error is caused by the fact that the name field is hidden using form states but the form field is marked required. Client-side validation will error on the empty name field, but since the field is hidden it throws a console error. The user gets no feedback as to why clicking submit fails.

This was introduced in ✨ Add ability to document non entities Fixed when the name field was moved out of the "hidden" region in Drupal. Drupal core will ensure that fields marked required and hidden don't have any conflicts in that case, but now it's up to this module to handle it instead.

Steps to reproduce

  1. Install fresh Drupal 10 and latest dev release of this module
  2. Enable "Make node entity documentable." in this modules settings
  3. Go to the "Add content model document" form
  4. Select a node type for the "Documentation for" field (in my case node.article)
  5. Click Save
  6. Nothing happens
  7. Check dev tools and find the error

Proposed resolution

Ensure the required attribute of the name field is also dealt with, possibly with form states β†’ .

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States rocketeerbkw Austin, Tx

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024