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.
Update documentation to:
Active
11.0 π₯
Last updated