How to use modal window (basic use) _php example in Yii2

Source: Internet
Author: User
Tags yii

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.