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