Problem/Motivation
FormBuilder::prepareForm()
adds a form_build_id
element, which is a hidden input, for example:
<input autocomplete="off" data-drupal-selector="form-v8temxqitapn2hablkw4gfmqyls0f5pmiy9tcd3p5gy" type="hidden" name="form_build_id" value="form-V8tEmXQITAPn2hAblkW4gfMQYls0F5pmiy9tCd3P5GY" />
This is invalid HTML, as confirmed by the W3 HTML Validator:
An input element with a type attribute whose value is hidden must not have an autocomplete attribute whose value is on or off.
This error gets flagged by automated accessibility testing software, such as SortSite.
Bad value for attribute autocomplete.<input autocomplete="off" data-drupal-selector="form-v8temxqitapn2hablkw4gfmqyls0f5pmiy9tcd3p5gy" type="hidden" name="form_build_id" value="form-V8tEmXQITAPn2hAblkW4gfMQYls0F5pmiy9tCd3P5GY" />
Looking back at the git history, autocomplete=off
was added back in 2018 by #2596597: [regression] Soft reload does not clean up user inputs like in D7 (Firefox only) to fix a bug with Firefox browsers.
I have tested removing autocomplete=off
and tried to reproduce the bug described in the original ticket and have been unable to reproduce the error with this fix removed. This leads me to think that either the Firefox browser has fixed the underlying issue since then, or something else within core has changed which solves it a different way. Either way, I think it's safe to remove.
Steps to reproduce
- Log in and go to a node add form
- View source and look for the hidden input element with name="form_build_id". It currently has autocomplete=off but this should be removed.
Proposed resolution
Remove autocomplete=off
from FormBuilder::prepareForm()