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()
Comment | File | Size | Author |
---|---|---|---|
#18 | 3320467-nr-bot.txt | 90 bytes | needs-review-queue-bot |
Issue fork drupal-3320467
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
nicrodgersComment #4
nicrodgersComment #5
jonnyhocks CreditAttribution: jonnyhocks at Welsh Government commentedReviewed the MR and tested (also with SortSite).
Comment #6
alexpottWe have to be very sure that this is fixed in Firefox - it might have been fixed by https://bugzilla.mozilla.org/show_bug.cgi?id=1752250 but https://bugzilla.mozilla.org/show_bug.cgi?id=520561 is still open.
I think we should have some test HTML from one of those issues where we can prove that this no longer happens. It would be great if @nicrodgers could detail exactly what steps were taken to prove this has been fixed in Firefox.
Comment #7
nicrodgersTo test this in Firefox, I followed the steps to replicate from the linked issue:
Steps to reproduce:
Actual result:
* Only one new item was there, which is correct. Tested in Firefox 106.0.3 (64-bit) on Linux.
I'll set it back to Needs Review and see if we can get some more people to test it on a range of different Firefox versions and platforms.
Comment #8
smustgrave CreditAttribution: smustgrave at Mobomo commentedIf this is a bug then we will need a test to make sure it doesn't come back.
Comment #10
guptahemant CreditAttribution: guptahemant as a volunteer and at QED42 for Salsa Digital commentedI also encountered the mentioned invalid HTML issue in on one of my projects and when i tried the patch from #3, it caused the original problem (https://www.drupal.org/project/drupal/issues/2596597) to appear back on Firefox browser.
Note: On my project i tested the behaviour with an entity reference field with cardinality set as unlimited.
Device and browser information
Firefox version: 108.0.1 (64-bit)
System details: MacBook Pro with OS version 12.0.1
Hence i think we can not commit this patch until the problem is resolved at Firefox browser itself.
Previously reported issues have been closed at firefox side, hence added a new one, https://bugzilla.mozilla.org/show_bug.cgi?id=1808843
Comment #11
andypostThe last issue is closed as well, so instead of test we can revert old commit
Comment #12
lauriiiWe don't have a FF test suite so this needs to be covered by manual tests.
Comment #13
smustgrave CreditAttribution: smustgrave at Mobomo commentedFollowing the steps in #7 I got the same result with 2 new items being generated.
And this was with MR 2941 applied.
Comment #14
andypostAnd today Firefox 117 is out (fixed in 108)
Comment #17
Liam MorlandI have updated the issue fork. The merge request needs to be set to target branch
11.x
. I believe only the owner of the merge request, @Nic Rodgers, is able to do this.Comment #18
needs-review-queue-bot CreditAttribution: needs-review-queue-bot as a volunteer commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #19
nicrodgersThanks @Liam. I've changed the target branch to 11.x
Setting back to Needs Review. We need people to test with latest firefox versions (see #14)
Comment #20
smustgrave CreditAttribution: smustgrave at Mobomo commentedSeems to be an odd failure in cspell. May need a rebase.
Comment #21
Liam MorlandRebased. Spelling test now passes.
Comment #22
smustgrave CreditAttribution: smustgrave at Mobomo commentedTested in firefox with the MR applied and not noticing form_build_id appear
Comment #25
catchCommitted/pushed to 11.x and cherry-picked to 10.3.x, thanks!