Z
Z
ZaurK2018-02-15 10:07:47
Yii
ZaurK, 2018-02-15 10:07:47

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

2 answer(s)
D
Dmitry, 2018-02-15
@slo_nik

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?

A
Anton, 2018-02-15
@Eridani

And what's stopping you from passing all this in rezalta and putting the forms into different keys of the main input array?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question