Showing posts with label yii2-bootstrap-modal-popup. Show all posts
Showing posts with label yii2-bootstrap-modal-popup. Show all posts

Tuesday, May 1, 2018

yii2 bootstrap modal popup

For implementing this you need to call default modal of Yii2 and begin and end modal is must

In step 2 you need to add javascipt for call the modal on button click.

In step 3 you need to create a action which render the data into your view.

How to add bootstrap modal in yii2

Add in your view:
//php code
Modal::begin([
    'header' => 'your header',
    'id'=>'modal',
     size'=>'modal-lg',
]);

echo '';

Modal::end();

Html::button('Button Name', ['value' => Url::to(['url/to']), 'title' => 'Title', 'class' => 'showModalButton btn btn-success']);

//javascript code
$('button').click(function(){
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
})

Add in your controller/action:
//php code
if(Yii::$app->request->isAjax){
        return $this->renderAjax('your-view-file', [
            'data' => $data,
        ]);

Recent Update

yii2 session handling

use yii\web\Session; $session = Yii::$app->session; // start session $session->open(); // close session $session->close(); ...

Most Search