Say you have nested forms in rails, which is only nested to accomodate the layout (in other words have nothing to do with each other, and should be submitted completely seperately)
假设您在rails中嵌套了表单,它只是嵌套以容纳布局(换句话说,彼此无关,应该完全单独提交)
for example
= form_tag update_custom_stock_admin_shop_products_path(@current_shop), method: 'put' do
...
...
= form_tag change_range_admin_shop_products_path(@current_shop), remote: true do
...
submit_tag 'change'
...
...
submit_tag 'submit'
How do I ensure that only the inner form is submitted when the inner submit ('change') is clicked, and the same for the outer form.
如何在单击内部提交(“更改”)时确保仅提交内部表单,并且外部表单也相同。
And please, do not tell me to use form_for
instead. Because I am using custom parameters and interpreting them manually with params
. If you do not know the answer, I kindly ask that you ignore my question and do not downvote or tell me it's better to use form_for
请不要告诉我使用form_for。因为我使用自定义参数并使用params手动解释它们。如果您不知道答案,我恳请您忽略我的问题,不要贬低或告诉我最好使用form_for
1 个解决方案
#1
-1
Nested forms don't really work. According to the html5 spec you shouldn't have them at all. You can have multiple forms per page though. You'll probably need to rethink the logic and use multiple remote forms.
嵌套表单不起作用。根据html5规范,你根本不应该拥有它们。但是,每页可以有多个表单。您可能需要重新考虑逻辑并使用多个远程表单。
Here's the html5 spec: https://www.w3.org/TR/html5/forms.html#the-form-element. Note:
这是html5规范:https://www.w3.org/TR/html5/forms.html#the-form-element。注意:
4.10.3 The form element
Content model:
Flow content, but with no form element descendants.
#1
-1
Nested forms don't really work. According to the html5 spec you shouldn't have them at all. You can have multiple forms per page though. You'll probably need to rethink the logic and use multiple remote forms.
嵌套表单不起作用。根据html5规范,你根本不应该拥有它们。但是,每页可以有多个表单。您可能需要重新考虑逻辑并使用多个远程表单。
Here's the html5 spec: https://www.w3.org/TR/html5/forms.html#the-form-element. Note:
这是html5规范:https://www.w3.org/TR/html5/forms.html#the-form-element。注意:
4.10.3 The form element
Content model:
Flow content, but with no form element descendants.