Answer the question
In order to leave comments, you need to log in
How should two different forms be placed on the same page in yii2?
Hello! There was a task to place two different forms on one page.
I use yii2 basic, I have a one-page site, as I understand it, in the main template you can display the form in the place where the $content variable is displayed, I displayed this variable twice in the places where these forms should be. But the problem is that this is the same form, and it works in such a way that if I send data from one, then the second one returns a submission notification in the same way. So, probably, we need to make two models and two actions and two views, let's say I do this, but still I don’t understand how then to display these forms in two places of the template? Is it possible to use another variable along with the $content variable? Or is there a better solution?
Answer the question
In order to leave comments, you need to log in
Good morning.
If the forms send a different set of data, then yes, two models and two actions in the controller. If the forms work with the same model, then just use scripts.
Two types are not required.
If you place two forms on one page, then for each form an individual id. Although not necessarily, depending on how you send them.
What for? Where exactly are you going to display these forms, in what view?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question