Hello good day,
Is there any one help me out, how to handle multiple forms on a single page.
i want a search form on top nav bar and a check out form client.
how to handle multiple forms on a single page ?
3 years ago
3 years ago
#1
3 years ago
#2
Maybe I am not fully understanding your question but providing you declare your forms correctly on the page and point each one to a different form handling function in your controller then there shouldn't be a problem as you will only get the fields within a form being submitted.
This means for example that if you have two forms on the page, form1 and form2 with the form action of form1 pointing to a function in the controller called form_1 and the action on form2 pointing to a function in the controller called form_2 then you will only see the fields from form1 being posted to function form_1 and likewise for form2.
You can easily test this out using the excellent json($data) function that Trongate provides.
Not sure if that explanation answers your question but if not then please provide more details of the scenario.
This means for example that if you have two forms on the page, form1 and form2 with the form action of form1 pointing to a function in the controller called form_1 and the action on form2 pointing to a function in the controller called form_2 then you will only see the fields from form1 being posted to function form_1 and likewise for form2.
You can easily test this out using the excellent json($data) function that Trongate provides.
Not sure if that explanation answers your question but if not then please provide more details of the scenario.
3 years ago
#3
If both forms are submitted when a Submit button is clicked.
Then you can separate the data when you Get Data from Post.
Then you can separate the data when you Get Data from Post.
3 years ago
#4
hello, thanks for reply, I understand ,
my both form work fine on a page , but the problem is the validation_error message show form_1 or top of the page .how i show the validation_error on form input position. or custom validation for every field.
please help.
my both form work fine on a page , but the problem is the validation_error message show form_1 or top of the page .how i show the validation_error on form input position. or custom validation for every field.
please help.
3 years ago
#5
Have you looked here:
https://trongate.io/docs/information/custom-validation-callbacks
In form validation here:
https://www.youtube.com/watch?v=Yo4i26ePwro
https://trongate.io/docs/information/custom-validation-callbacks
In form validation here:
https://www.youtube.com/watch?v=Yo4i26ePwro