Built in form system documentation update

Created on 17 February 2024, 7 months ago
Updated 18 February 2024, 7 months ago

Problem/Motivation

The Drupal documentation is lacking information on the out of the box forms behavior.
Old versions of Drupal (7 and possibly previous) allowed modifying from elements using hook_form_alter.
Things like modifying a field's placeholder could be done by editing
$form["message"]['#attributes']["placeholder"]
the form element attributes could also be altered allowing for things such as specifying a textarea col attribute.
Drupal 8 and beyond seem to have undergone an architectural change which has deprecated this possibility. My limited understanding leads me to believe that the display of a form element has been moved to the widget while the form data itself is only about the nature of the form elements from a data storage/state perspective.
The Drupal documentation does not mention any of this in what seems to be the obvious place to go to get started: introduction-to-form-api β†’
It would be nice to update the documentation to point to an explanation of the architectural changes that led to this separation between data definition and form elements display and provide hints to alternative ways to achieve the previously possible modifications on a form's built-in elements. added elements have an editable widget that allows such changes but are in some respects missing options. for example a textarea widget does not allow setting the number of columns of the textarea, only the rows can be edited - while this is not a practical issue as css can be used to control those aspects, it is an architectural issue which is especially noticeable in cases of headless drupal instances where we'd want to communicate a form to any type of front-end along with any relevant parameters.

Steps to reproduce

Proposed resolution

Update documentation to:

  • point an architectural explanation of the separation between display and data definition information.
  • point to ways to alter the form elements attributes (placeholder, cols, rows, size etc...)

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

πŸ’¬ Support request
Status

Active

Version

11.0 πŸ”₯

Component
FormΒ  β†’

Last updated 1 minute ago

Created by

πŸ‡±πŸ‡§Lebanon vitch

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

Comments & Activities

Production build 0.71.5 2024