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,
]);
This comment has been removed by the author.
ReplyDelete
ReplyDeleteIt is nice post and I found some interesting information on this blog, keep it up. Thanks for sharing. . .
Remote Yii Framework Team
Good day. I was impressed with your article. Keep it up . You can also visit my site if you have time. Thank you and Bless you always.
ReplyDeleteRemote Yii Framework Development in India