本文整理汇总了PHP中Commande::setScenario方法的典型用法代码示例。如果您正苦于以下问题:PHP Commande::setScenario方法的具体用法?PHP Commande::setScenario怎么用?PHP Commande::setScenario使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Commande
的用法示例。
在下文中一共展示了Commande::setScenario方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSignup
/**
* Handles the first page of the application form
* @param string $city
*/
public function actionSignup($city)
{
$customer_model = new Customer();
$commande_model = new Commande();
$goodcity = Goodcity::model()->findByPk($city);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
// Set the scenario to limit the attributes we suck in from
// the POST array. This protects us against injection attacks.
$commande_model->setScenario('user_create');
$customer_model->setScenario('user_create');
if (isset($_POST['Customer'])) {
// Populate our new models from the input arrays
$customer_model->attributes = $_POST['Customer'];
$commande_model->attributes = $_POST['Commande'];
// If a model saves, we know it's valid
if ($customer_model->validate()) {
// Save the uploaded files
$arr_uploads = array('dest_idpicture11', 'dest_idpicture12', 'dest_idpsform1', 'dest_idpicture21', 'dest_idpicture22', 'dest_idpsform2', 'dest_idpicture31', 'dest_idpicture32', 'dest_idpsform3');
foreach ($arr_uploads as $upload) {
$commande_model->{'t' . $upload} = CUploadedFile::getInstance($commande_model, $upload);
}
// We have to insert a dummy id here to run validate()
$commande_model->bilkey = 0;
if ($commande_model->validate()) {
// Save the uploaded files
$arr_uploads = array('dest_idpicture11', 'dest_idpicture12', 'dest_idpsform1', 'dest_idpicture21', 'dest_idpicture22', 'dest_idpsform2', 'dest_idpicture31', 'dest_idpicture32', 'dest_idpsform3');
foreach ($arr_uploads as $upload) {
$commande_model->{$upload} = CUploadedFile::getInstance($commande_model, $upload);
if ($commande_model->{$upload} != null) {
$path = $this->getUploadPath($commande_model->{$upload});
$commande_model->{$upload}->saveAs($path);
$_POST['Commande'][$upload] = $path;
}
}
// We don't actually want to do the save just yet,
// so store *everything* in the session. (This is hack-y)
Yii::app()->user->setState('Customer', $_POST['Customer']);
Yii::app()->user->setState('Commande', $_POST['Commande']);
Yii::app()->user->setState('payment_type', $_POST['payment']);
//var_dump($this->emailValidation($customer_model));die();
if ($this->passwordUsernameVerification($customer_model) == false) {
$this->render('application/1-signup', array('goodcity' => $goodcity, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'onetime' => false, 'username_used' => true));
die;
} elseif ($this->emailValidation($customer_model) == false) {
$this->render('application/1-signup', array('goodcity' => $goodcity, 'customer_model' => $customer_model, 'commande_model' => $commande_model, 'onetime' => false, 'email_used' => true));
die;
}
$this->redirect(array('order'));
}
} else {
// We have to insert a dummy id here to run validate()
$commande_model->bilkey = 0;
$commande_model->validate();
}
} elseif (isset(Yii::app()->user->Customer)) {
$customer_model->attributes = Yii::app()->user->Customer;
$commande_model->attributes = Yii::app()->user->Commande;
// $payment_type = Yii::app()->user->payment_type;
}
// Hack for one-time setup option
$onetime = false;
if (isset(Yii::app()->user->onetime)) {
$onetime = true;
} else {
$onetime = false;
}
$this->render('application/1-signup', array('customer_model' => $customer_model, 'commande_model' => $commande_model, 'goodcity' => $goodcity, 'onetime' => $onetime));
}