Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
XHTML requires that the id attribute begin with a letter. form_build_id is set to an MD5 hash so 10 times out of 16 it begins with a number. This patch just puts an 'f' at the front of every form_build_id.
It is not clear to me why we are outputting an id field containing a randomly-generated hash in the first place. How can it ever be useful? Scripting, I guess.
Comment | File | Size | Author |
---|---|---|---|
#4 | xhtml-valid-form-id.patch | 1.07 KB | Stefan Nagtegaal |
form-build-id.patch | 1.08 KB | bjaspan | |
Comments
Comment #1
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedIsn't it nicer todo:
instead of:
Just my $0,02..
Comment #2
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedSet better title
Comment #3
nedjoYes, we should make this change.
I agree that 'form-' is a better prefix.
Comment #4
Stefan Nagtegaal CreditAttribution: Stefan Nagtegaal commentedUpdated code, that works!
Comment #5
Dries CreditAttribution: Dries commentedCommitted! Thanks.
Comment #6
eaton CreditAttribution: eaton commentedFor the record, we do this because it allows us to identify, via the incoming $_POST data, what specific version of a form is coming in. Not just the form's identification (like, 'node-story-form') but the specific instance of that form, built on a particular page at a particular time for a particular user.
This is particularly useful when AJAX code is making client-side modifications to a form; it can relay information back to the server to keep the server side validation code in sync with the client side form, for that particular instance.
Comment #7
bjaspan CreditAttribution: bjaspan commentedEaton,
No, you are outputting a hidden form field whose value is a randomly-generated hash for that purpose. Outputting an id field as well has no such benefit as id fields are not transmitted back to the server. It has very little cost and I suppose it can help with debugging, but it has no benefit in any other case I can think of.
Comment #8
eaton CreditAttribution: eaton commentedThanks for the clarification, I misread your post. You are correct that the hidden field serves that purpose.
Comment #9
bjaspan CreditAttribution: bjaspan commentedOkay. I'm glad to know I'm not crazy. :-)
Comment #10
(not verified) CreditAttribution: commented