How to popup a form in yii2?

Hello,

I used a widget in yii and need to popup a php file in a window in yii2.

Thanks

You can call another view in a popup/modal windows using bootstrap as follows:




<?php

            Modal::begin([

                'toggleButton' => [

                    'label' => '<i class="glyphicon glyphicon-plus"></i> Add',

                    'class' => 'btn btn-success'

                ],

                'closeButton' => [

                  'label' => 'Close',

                  'class' => 'btn btn-danger btn-sm pull-right',

                ],

                'size' => 'modal-lg',

            ]);

            $myModel = new \frontend\models\SomeModel;

            echo $this->render('/someview/create', ['model' => $myModel]);

            Modal::end();

        ?>



Thank you

Hi sifa786, it works, but it can not save the data from the popup form to the database. is there any code missing?

Hi,

Refer this link it may helpful.

http://www.yiiframework.com/wiki/806/render-form-in-popup-via-ajax-create-and-update-with-ajax-validation-also-load-any-page-via-ajax-yii-2-0-2-3/