Key is not automatically populated after validation failure on blank title

Created on 2 May 2019, almost 6 years ago
Updated 4 March 2023, about 2 years ago

Problem/Motivation

When editing the title field, the key (or machine name) field is not updated. This happens when the form was first submitted without a value in the title field.
The key field should be automatically populated from the title value, as it is before the validation failure.

Example forms where the issue occurs

  • Role add: /admin/people/roles/add
  • Field add:/admin/structure/types/manage/{node_type}/fields/add-field
  • Webform field add

Steps to reproduce

  1. When adding a field, leave the title field blank
  2. Click "Save"
  3. As expected, validation fails
  4. Enter a value in the title field
  5. Click "Save"
  6. A value for the machine name needs to be entered.

Proposed resolution

TBA

Remaining tasks

check for duplicates
patch
review
commit

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Active

Version

10.1

Component
Form 

Last updated 1 day ago

Created by

🇬🇧United Kingdom malcomio

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇿New Zealand quietone

    Still trued on Drupal 10.1.x

  • Assigned to jaydev bhatt
  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    i'm working on this issue.

  • 🇮🇳India jaydev bhatt Pune, Maharashtra

    Issue Analysis: Form Validation in Content Type and Role Creation

    I have thoroughly tested this reported issue in Drupal versions 10.4.1 and 11.1.1, focusing on two key scenarios:

    1. Content Type Creation
    - Access Path: /admin/structure/types/add
    - Test Methodology: Attempted to create a content type with an empty "Name" field
    - Observed Behavior:
    * Form validation is handled through HTML5 attributes
    * The system successfully prevents submission with empty required fields
    * When a name is provided, the machine name is automatically generated

    2. Role Creation
    - Access Path: /admin/people/roles/add
    - Test Methodology: Attempted to create a role with an empty "Name" field
    - Observed Behavior: Similar validation behavior as content type creation

    Conclusion:
    The reported issue is not reproducible in current versions. The form validation is functioning as expected through HTML5 form validation attributes, preventing submission of empty required fields.
    Attaching a screenshot for the reference for the testing done on drupal 10.4.1 and 11.1.1

    Recommendation:
    - Status can be updated to "Needs Review"
    - If validation confirms these findings, status can be moved to "Ready to be Committed" (RTBC)

  • 🇮🇳India Kanchan Bhogade

    I have manually tested issue on Drupal 11.x but Key is populated after validation failure on blank title.

    Validation is already compatible for latest version

  • 🇺🇸United States smustgrave

    There's nothing to commit so odds are this can be closed out as outdated or unable to reproduce. Putting to PNMI for someone to provide steps if they are still seeing this issue before closing out.

Production build 0.71.5 2024