Disabled and readonly form element attributes should be boolean HTML5 attributes

Created on 18 September 2023, 9 months ago
Updated 20 October 2023, 8 months ago

Problem/Motivation

The current HTML5 specification for the "disabled" and "readonly" attributes of form elements allows their values to be specified as either a boolean attribute or a string attribute. However, this has led to confusion and inconsistencies in implementation across various browsers and platforms.
To improve the clarity and standardization of the HTML5 specification, there is a need to redefine these attributes as purely boolean attributes. This change would ensure that these attributes are used uniformly across different web browsers and platforms, thereby enhancing the accessibility and usability of web forms for users.

The proposed adjustment aims to streamline the behavior of the "disabled" and "readonly" attributes, providing developers with a more consistent and predictable approach to implementing these attributes in their web forms. This modification would contribute to a more coherent and intuitive web development experience and facilitate a smoother user interaction with forms across various devices and platforms.

The code in FormBuilder::handleInputElement():

    if (!empty($element['#disabled'])) {
      if (!empty($element['#allow_focus'])) {
        $element['#attributes']['readonly'] = 'readonly';
      }
      else {
        $element['#attributes']['disabled'] = 'disabled';
      }
    }

Steps to reproduce

Identify the FormBuilder class in the codebase.

Locate the handleInputElement method within the FormBuilder class. Ensure you have access to the source code for this method.

Proposed resolution

Update the HTML5 specification to define the "disabled" and "readonly" attributes as boolean attributes only.

These should actually be boolean attributes:

    if (!empty($element['#disabled'])) {
      if (!empty($element['#allow_focus'])) {
        $element['#attributes']['readonly'] = TRUE;
      }
      else {
        $element['#attributes']['disabled'] = TRUE;
      }
    }

Remaining tasks

Revise relevant documentation, including developer resources and browser documentation, to reflect the updated specification.

Communicate the changes to the web development community and documentation updates to ensure awareness and understanding of the revised attributes.

Provide clear guidelines and best practices for web developers on utilizing the updated "disabled" and "readonly" attributes in their HTML forms.

User interface changes

API changes

Data model changes

Release notes snippet

📌 Task
Status

Needs work

Version

11.0 🔥

Component
Form 

Last updated about 1 hour ago

Created by

🇺🇸United States Dave Reid Nebraska 🇺🇸

Live updates comments and jobs are added and updated live.
  • html5

    Implements and supports the use of HTML5.

  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Production build 0.69.0 2024