This project is archived and is in readonly mode.
FormTagHelper#submit_tag with :disable_with option doesn't submit the button's value when clicked
-
Jose Fernandez
Clarification: The submit_tag original value is the one that gets submitted, not the disable_with one.
-
Jonathan Dance
If this is a bug, the patch would be more awesome if it had a test that would fail without this patch, e.g. the value of the submit button should be passed when using :disable_with.
-
Jose Fernandez
- Tag changed from actionpack, helper, patch, tested to actionpack, bug, helper, patch, tested
The problem with that is how to simulate a click on the submit_tag and a mocked form submission (in order to check that the hidden input fields gets successfully created and passed long the request).
I think as long as the modified submit_tag tests do a dom check that includes the extra js, its all good.
-
Jonathan Dance
Hm, I guess it would require Selenium (or something similar). Oh well, it was a good thought.
+1
-
Pratik
- Title changed from [PATCH] FormTagHelper#submit_tag with :disable_with option doesn't submit the button's value when clicked to FormTagHelper#submit_tag with :disable_with option doesn't submit the button's value when clicked
-
Lawrence Pit
I think you need to test whether the hidden field already exists or not. This is because the form can have a custom onsubmit handler (doing some ajax stuff for example). When that fails, the submit button is enabled again. When you press submit again, the current patch will again add a hidden field.
-
Jose Fernandez
I was actually thinking about that issue recently, will update patch tomorrow
-
Jose Fernandez
Updated the patch with a a check to see if the reference to the dynamically created (hiddenCommit) element exists in the window object before creating and appending it again.
Tests have also been updated, all passed too.
-
spovich
+1
We were bitten by this bug. Would love to see this fixed in Rails 2.1.1
-
Pratik
- Assigned user set to Pratik
-
Ryan Bates
+1, I've run into this problem before too.
But does this patch handle the case where a different button is pressed after the original onsubmit failed? Maybe add an "else" condition if the hidden field exists and override the value there.
-
Jose Fernandez
Good idea Ryan, updating the patch atm.
-
Jose Fernandez
Here's the updated patch. It will check the window DOM object for the hiddenCommit element and update the value if it already exists, or create it otherwise.
I also stopped using the array of strings + joining with ';' way of writing the javascript since it was causing problems with the if/else js statements.
Tests were also updated, both passed.
-
Jose Fernandez
Oh yeah, and I also switched the += operator with << at line 363.
-
DHH
- State changed from new to committed
-
Han Kessels
This patch breaks the :disable_with option on all versions of Internet Explorer.
IE does not allow the modification of the type attribute of an element. This can be fixed by replacing cloneNode on the submit input element in the original patch by the creation of a new hidden input element. A small patch with updated tests is attached.
