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.
Hi,
when i submit a form first time this module works fine, but if a required field is left blank, the page is submitted (not using client side validation) and as expected the missing fields message show, so a user fills it, now if you click submit again the module doesn't work, users can click 2 or 3 times submitting the form again and again.
it throws this error:
Uncaught TypeError: Cannot read property 'hide_submit_method' of undefined
Comments
Comment #1
jonloh CreditAttribution: jonloh commentedWe will need to add the JS and CSS in #after_build as well. The patch attached should fix this issue.
Comment #2
stupiddingo CreditAttribution: stupiddingo commentedWe were seeing the same behavior on form validation error and resubmit. This patch resolves the error.
Comment #3
gregglesI tried to replicate this error:
1. on a custom form that has required fields I filled in 2 of the fields and hit submit, the button hides
2. I get an error that the field is required
3. I fill in the field and hit submit again, the button disappears as expected
Are there any more steps to replicate the error? What kind of form were you using?
Comment #4
stupiddingo CreditAttribution: stupiddingo commented:crickets: ...nearly a year passes... sorry about that!
Steps to replicate
1. Install Drupal with standard profile
2. Download and enable hide submit 7.x-2.x-dev
3. Open Internet Explorer (yes, really... I know, I know. In some builds of Firefox you can do this as well)
3. Submit an article without a title (validation will fire)
4. Add a title and some serious content to slow things (The Wikipedia article for World War II was sufficiently verbose https://en.wikipedia.org/wiki/World_War_II)
4. Resubmit double-clicking like you are using Windows 3.1 (for best results just keep clicking)
In Internet Explorer console you can see this error:
Even Chrome is opinionated about this but I can't make multiple submissions successfully:
The patch https://www.drupal.org/files/issues/hide_submit-uncaught-typeerror-when-... resolves this behavior in all my tests on IE, Chrome and Firefox.
Comment #5
rymcveighI was able to replicate the issue on FF ver. 41.0.2 Mac on both simplytest.me and a clean VM install, I was unable to create multiple pages with Chrome Version 46.0.2490.80 (64-bit) Mac, and was able to replicate the issue on IE 10 Windows 7 on a clean VM install. Using the latest ver. of the module and Drupal 7.
FF Content:
FF Console:
IE Content:
IE Console:
Comment #6
stupiddingo CreditAttribution: stupiddingo commentedIn my testing I was able to create duplicates on:
- Internet Explorer 11.0.9600.17728 (and older versions in compatibility mode)
- Firefox 41.0.2 & Firefox 42.0 (Windows)
Here you can see the dups created in the same second on IE and Firefox:
While this testing was done on Acquia Dev Desktop, I have had the same behavior happening from IE visitors on my production sites hosted on both WIMP and LAMP.
Ryan, sorry but I'm not following your comment. You're unable to create duplicates, yet the drupal message on node create is repeated? What am I missing? I suspect on /admin/content you'd see double posts in those scenarios.
Comment #7
stupiddingo CreditAttribution: stupiddingo commentedApparently I can't read well this morning.
/me goes and gets some more coffee.
My bad Ryan. I missed the "able to replicate".
Comment #8
rymcveighSorry, I'm working through it as I go. Here is what I'm seeing on FF after the initial fail. Looks like it could be due to a jquery issue:
Comment #9
rymcveighNo worries. I was actually able to create 4 instances of content on IE 10 win 7 with the setting on the module set to disable. So, yeah, its an issue. I'm going to test with jQuery update just to see if using an updated version of jQuery helps.
Comment #10
rymcveighI ran a series of tests using different configs with and without jquery_update, here are the results:
With jQuery update disabled and Hide submit button set to "hide submit buttons" I was able to create 4 nodes at once.
With jquery update disabled and Hide submit button set to "disable submit buttons" I was NOT able to create more than one node at a time.
With jquery update enabled and set to jquery ver. 1.7, and Hide submit button set to "disable submit buttons" I was able to create 2 nodes at once.
With jquery update enabled and set to jquery ver. 1.8, and Hide submit button set to "disable submit buttons" I was NOT able to create more than 1 node at once.
With jquery update enabled and set to jquery ver. 1.8, and Hide submit button set to "hide submit buttons" I was NOT able to create more than 1 node at once BUT the btn did not hide.
With jquery update enabled and set to jquery ver. 1.7, and Hide submit button set to "hide submit buttons" I was NOT able to create more than 1 node at once BUT the btn did not hide.
With jquery update enabled and set to the default supplied by drupal, and Hide submit button set to "hide submit buttons" I was able to create 2 nodes at once AND the btn did not hide.
With jquery update enabled and set to the default supplied by drupal, and Hide submit button set to "disable submit buttons" I was NOT able to create more than one node at once.
In IE 10 Win. 7 I was able to create multiple nodes with any of the above settings. IE once again wins the "Most likely to fail" award. :)
Comment #11
rymcveighI've tested this patch a couple times now and it seems to have resolved the issue. Stupiddingo, when you have a moment, will you please review with this patch and let me know if it works for you? Thanks.
Instructions for applying patch: https://www.drupal.org/project/hide_submit/git-instructions
Comment #12
rymcveighAdded adjusted patch. This new patch now needs to be reviewed.
Comment #13
rymcveighComment #14
stupiddingo CreditAttribution: stupiddingo commentedTested successfully using the articles method above, highly customized node forms and webforms on the following:
- Android: Chrome, Firefox
- Linux: Chromium, Firefox
- iOS: Safari
- Windows: IE11, Chrome, Firefox
Bonus! It now correctly hides the "Delete" button as well which over enthusiastic data editors of mine were successfully clicking in double-clicking the save button on edits and consequently performing the unfortunate "uplete" submission.
This patch may also resolve these issues:
https://www.drupal.org/node/2393923
https://www.drupal.org/node/2388697
Comment #15
gregglesCool, committed now. Thanks Ryan, jonloh and stupiddingo!