Modal is also the modal window, the popular saying is the window. is a bootstrap JS plug-in, the use of the effect is very good.
Why to use modal is needless to say, a website, in the development process you said you did not use JS window I do not believe! A good window not only gives people aesthetic, but also allows us to develop efficiency, and even the mood will be comfortable!
Let's see how to use modal in Yii2.
For example, when we add data, we usually click the button to jump to the Add page, save and then jump to the list page.
Now we want to click the Add button, in the current page window to add data to see the specific implementation.
1, use Yii\bootstrap\modal;
2. Create a button to tune the modal display
echo html::a (' Create ', ' # ', '
id ' => ' create ',
' data-toggle ' =>
' modal ', ' Data-target ' => ' #create-modal ',
' class ' => ' btn btn-success ',
];
3. Create Modal
<?php
modal::begin ([
' id ' => ' create-modal ', '
header ' => '
This time we click the button [create], will see modal window, screenshot below.
Some students may say that this page does not need to be loaded asynchronously. Indeed, you can also echo $this->renderajax () directly on the page, but you need to be reminded that this action remembers modifying the action of the form submission.
For the use of modal, here are two points to remind you:
Set the property data-toggle= "modal" on the control element (such as a button or link) and set the data-target= "#identifier" or href= "#identifier" to specify the specific modal box to toggle (with id= " Identifier ")
Above, we have realized the basic use of modal in Yii2.