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.
Problem/Motivation
A logical bug allows the form submit handler to be bound multiple times when there are multiple forms on the page.
Proposed resolution
Limit to a single submit handler bound, per form.
Comment | File | Size | Author |
---|---|---|---|
#8 | hide_submit-2559585-8-submit-handler-bound-multiple-times.patch | 783 bytes | geek-merlin |
Comments
Comment #2
jtwalters CreditAttribution: jtwalters commentedThis patch may also fix the following issues:
- #2393923: Buttons get mixed up
- #2086887: Limit the action to the clicked form
- #2304087: The timer fails when one page contain multiple forms
Comment #3
gregglesThis seems likely to require a re-roll after #2317141: Uncaught TypeError when resubmitting a form that had a missing required field was committed. Can you do that?
Comment #4
alexandrdnlv CreditAttribution: alexandrdnlv as a volunteer commentedHi I've updated a little bit a patch to work with 7.x-2.2. and 7.x-2.x versions (attached both of them).
Comment #5
geek-merlinI can't see how the code should fix the problem by only dropping context. Instead this should be wrapped in a JS once().
Look into this:
https://www.lullabot.com/articles/understanding-javascript-behaviors-in-...
Comment #6
jtwalters CreditAttribution: jtwalters commentedIt's already using the once() method, the problem is that the selector can grab un-related forms on the document context.
Comment #7
jtwalters CreditAttribution: jtwalters commentedComment #8
geek-merlin> It's already using the once() method
Well, partly right, that code is part of a large once() block, see:
http://cgit.drupalcode.org/hide_submit/tree/js/hide_submit.js?id=07b7078...
So then applying the selector again is wrong, but removing context also.
Instead we should simply use $form.
Patch flying in, please test.