本文整理汇总了PHP中Clients::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Clients::validate方法的具体用法?PHP Clients::validate怎么用?PHP Clients::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Clients
的用法示例。
在下文中一共展示了Clients::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));
}