New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Submit button with formaction outside of form tag #17805
Comments
<form></form>
and formaction
Do you want to submit a pull request fixing it? |
I have a feeling my fix is suboptimal, I fear update through pjax might make problems. |
Id should stay the same, to avoid conflicts when using Been a while since I've used jQuery but I think you'd need to include the current form so buttons within it are still picked up. $("[form=" + $form.attr("id") + "]").add($form).on('mouseup.yiiActiveForm keyup.yiiActiveForm', ':submit', function () {
$form.data('yiiActiveForm').submitObject = $(this);
}); |
Thx @alex-code that snippet helped finalizing it; pr done. |
form is actually more difficult to implement it seems, it is also related to yii.js, but it should at least work when data-form is used now.
What steps will reproduce the problem?
Create a form, and put the submit button outside of the form.
And set the "form" attribute to the id of the form (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button#attr-form).
Now set the formaction attribute on the button.
What is the expected result?
On pressing that button, it should submit the form to my formaction.
What do you get instead?
It is submitted to the action of the form.
Additional info
It uses
$form.on
, and then filters by":submit"
, since the submit button is not in the form, it is never going to setsubmitObject
.https://github.com/yiisoft/yii2/blob/master/framework/assets/yii.activeForm.js#L229
My current solution is:
The text was updated successfully, but these errors were encountered: