How to use modal pop-up window in yii2, yii2 use modal pop-up window _ PHP Tutorial

Source: Internet
Author: User
Yii2 uses modal pop-up window. How to use modal pop-up window in yii2: Author of modal pop-up window in yii2: White Wolf Source: www.manks.topyii2_modal_baseuse.html this article is copyrighted by the Author. You are welcome to reprint it, but not use modal pop, yii2 uses modal pop-up window

Author: White Wolf Source: http://www.manks.top/yii2_modal_baseuse.html this article copyright to the author, welcome to reprint, but without the author's consent must retain this paragraph of the statement, and in the article page clearly given the original connection, otherwise, you are entitled to pursue legal liability.

Modal is also a Modal window. In general, it is a pop-up window. Is a js plug-in for bootstrap, and the use effect is also very good.

I don't need to say much about the use of modal. I don't believe it when you say that you haven't used js pop-up windows during the development of a website! A good pop-up window not only gives us a sense of beauty, but also improves our development efficiency and even improves our mood!

Let's see how modal is used in yii2.

For example, when we add data before, we usually click the button to jump to the add page, save and then jump to the list page.

Now we want to add data in the pop-up window of the current page when you click the Add button. see the specific implementation.

1. use yii \ bootstrap \ Modal; 2. create a button to adjust the display of modal.
Echo Html: a ('create', '#', ['id' => 'Create', 'data-toggle '=> 'modal ', 'data-target' => '# create-modal', 'class' => 'btn btn-success',]);

3. create modal
 'Create-modal', 'header' => 'Create', 'footer '=> 'close',]); $ requestUrl = Url: toRoute ('create '); $ js = <
 
  
RegisterJs ($ js); Modal: end ();?>
 

4. modify the create operation as follows:
public function actionCreate(){    $model = new Test();    if ($model->load(Yii::$app->request->post()) && $model->save()) {        return $this->redirect(['index']);    } else {        return $this->renderAjax('create', [            'model' => $model,        ]);    }}

In this case, click [create] to see the modal pop-up window.

Some may say that this page does not need to be asynchronously loaded. Indeed, you can also directly echo $ this-> renderAjax (); on the page, but remember to modify the action submitted by the form.

For the use of modal, there are two points to remind you:

Above, we have implemented the basic usage of modal in yii2. We also talked about the use of modal-knot gridview in yii2. we recommend that you take a look.

[Considering that most of the articles collected on Chinese websites are very frequent at present, the author does not specify the source of the original article. the original author prefers the readers to check the original article to avoid updating all the articles due to any problems and avoid misleading.]

Continue reading

Author: White Wolf Source: http://www.manks.top/yii2_modal_baseuse.html文, welcome to download, but not...

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.