Yii2 - Render form inside footer (main.php) -


in main.php layout file, of yii2, need render form located in folder contacto/_form.

how can pass $model variable file main.php, inside layouts folder, , use in:

<?= $this->render('_form', [     'model' => $model, ]) ?> 

many thanks.

you can create widget that:

class formwidget extends widget {     /**      * @return string      */     public function run()     {         $model = ...;// code create model          return $this->render('_form', [             'model' => $model         ]);     } } 

and in layout input widget that:

<?= formwidget::widget() ?> 

for more read create widgets - http://www.yiiframework.com/doc-2.0/guide-structure-widgets.html#creating-widgets


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -