Answer the question
In order to leave comments, you need to log in
Using form object defined in layout inside another view?
Good afternoon, the following question arose: I define the form object in the layout - $form=ActiveForm::begin(). I want to use this object in another view, but Yii2 gives an error that the form object is not defined in this view, which, in principle, corresponds to the logic - I don’t define the $form object in this ... But how can I connect these objects? Is it possible to use the Block tool in this case - www.yiiframework.com/doc-2.0/yii-widgets-block.html ? The definition of $form in layout is necessary for me based on the layout.
Answer the question
In order to leave comments, you need to log in
There are methods, but terrible ones, such as storing a variable as public in the controller. I'm sure you're doing something fundamentally wrong. Describe the problem, not the method you chose to solve it. I don't see the need to start the form in layout and end it in view. This is some kind of stupidity.
Most likely, your task lies in the js plane, and you solve it on the server, hence such strange decisions.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question