本文整理匯總了PHP中Preferences::validate方法的典型用法代碼示例。如果您正苦於以下問題:PHP Preferences::validate方法的具體用法?PHP Preferences::validate怎麽用?PHP Preferences::validate使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Preferences
的用法示例。
在下文中一共展示了Preferences::validate方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: actionCreate
public function actionCreate()
{
$model = new Clients();
$account = new Accounts();
$preference = new Preferences();
if (isset($_POST['Clients'], $_POST['Accounts'], $_POST['Preferences'])) {
$model->attributes = $_POST['Clients'];
$account->attributes = $_POST['Accounts'];
$preference->attributes = $_POST['Preferences'];
$model->login_name = $account->login_name;
$model->client_code = RandomGenerator::generateString(AdminGlobals::CLIENT_CODE_LENGTH);
$model->subscription_status = "active";
$preference->prepaid_passwd = RandomGenerator::generateString(AdminGlobals::PREPAID_PASSWD_LENGTH);
$account->account_name = $model->client_name;
$account->email = $model->email;
$account->is_visible = 0;
$valid = $model->validate();
$valid = $account->validate() && $valid;
$valid = $preference->validate() && $valid;
if ($valid) {
$transaction = Yii::app()->db->beginTransaction();
$success = $model->save(false);
if ($success) {
$account->client_id = $preference->client_id = $model->id;
}
$success = $success && $account->save(false);
$success = $success && $preference->save(false);
if ($success) {
$transaction->commit();
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('view', array('model' => $this->loadModel($model->id), 'account' => $account, 'preference' => $preference), false, true);
Yii::app()->end();
}
$this->redirect(array('view', 'id' => $model->id));
}
$transaction->rollBack();
}
}
if (Yii::app()->request->isAjaxRequest) {
$this->renderPartial('create', array('model' => $model, 'account' => $account, 'preference' => $preference), false, true);
Yii::app()->end();
}
$this->render('create', array('model' => $model, 'account' => $account, 'preference' => $preference));
}