Yii implementation of multi-button save and submit method, YII Implementation button submitted _php tutorial

Source: Internet
Author: User
Tags yii

Yii implementation of multi-button save and submit method, YII implementation button submission


In this paper, we describe the implementation of the multi-button save and commit and do not conflict with Yii. This is a lot of beginners have encountered but do not know how to solve the problem, the following share to everyone for your reference. Here's how:

Only cform in Yii can use the submitted () method, using the IF ($form->submitted (' submit ')) to determine whether the button clicked ButtonName as Submit, for example:
Form:
Copy the Code Code as follows: ' Buttons ' =>array (
' Preview ' =>array (
' Type ' = ' Submit ',
' Label ' =>yii::t (' core ', ' Show preview '),
),
' Draft ' =>array (
' Type ' = ' Submit ',
' Label ' =>yii::t (' core ', ' Save draft '),
),
' Submit ' =>array (
' Type ' = ' Submit ',
' Label ' =>yii::t (' core ', ' Submit '),
),
Chtml::link (Yii::t (' core ', ' Cancel '), Yii::app ()->homeurl),
),

Controller:
Copy the code as follows: if ($form->submitted (' Submit '))
$model->status=post::status_proposed;
Else
$model->status=post::status_draft;
But Cactiveform does not have this approach, and one solution is to use classical HTML notation:
Copy the Code code as follows:>
if (Isset ($_post[' Submityes '))
On the line.

The final run effect looks like this:

It is hoped that this article is helpful to the PHP program design based on YII framework.

http://www.bkjia.com/PHPjc/920978.html www.bkjia.com true http://www.bkjia.com/PHPjc/920978.html techarticle YII Implementation of multi-button save and submit method, YII Implementation button submitted in this paper, the implementation of a multi-button save and submit and do not conflict implementation methods. This is a lot of beginners have encountered ...

  • 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.