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

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -