How to save and submit multiple buttons in Yii. how to submit multiple buttons in yii _ PHP Tutorial

Source: Internet
Author: User
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...

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.