Yii implements multiple button saving and submission methods, and yii implements button submission. Yii implements how to save and submit multiple buttons. the yii implementation button submits this article. this example describes how Yii implements multi-button saving and submission without conflict. This is a method used by many beginners to save and submit multiple buttons in Yii.
This example describes how to save and submit multiple buttons in Yii without conflict. This is a problem that many beginners have encountered but do not know how to solve. I will share it with you for your reference. The specific method is as follows:
In Yii, only CForm can use the submitted () method. if ($ form-> submitted ('submit ') is used to determine whether the button with buttonName as submit is clicked. for example:
Form:
The code is 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:
The code is as follows:
If ($ form-> submitted ('submit '))
$ Model-> status = Post: STATUS_PROPOSED;
Else
$ Model-> status = Post: STATUS_DRAFT;
However, CActiveForm does not use this method. a solution is to use classical html:
The code is as follows:
>
If (isset ($ _ POST ['submityes'])
That's all.
Shows the final running effect:
I hope this article will help you design PHP programs based on the Yii Framework.
Examples in this article describes how to save and submit multiple buttons in Yii without conflict. This is what many beginners have encountered...