'Laravel form inside another form
I am in a situation where I have one form inside another form. What I'm trying to achieve is when I submit the parent form, it is submitted to a defined URL however, when I submit the child form, it is submitted to a different URL.
I know its not possible in html to use nested forms but can anyone suggest any trick or tip by using JQuery or JavaScript so that submitting the child form disables the parent form?
Below is my HTML Structure:
<form action="{{url('checkout')}}" class="mt-5 check-out-form" method="post">
<form action="{{url('user/address')}}" class="mt-5 check-out-form" method="post">
<input type="submit" value="Update Address">
</form>
<input type="submit" value="CheckOut">
Solution 1:[1]
You should not attempt to nest forms within each other. The HTML standards state this.
"There can be several forms in a single document, but the FORM element can't be nested."
If you're comfortable with it, simply have two different forms for the different functionality or a single form that does it all.
Bottom line is there is never a logical reason to nest a form.
Solution 2:[2]
I think you should create a model outside the main form and call it
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Zeeno |
| Solution 2 | Youness Chakir |
