本文整理汇总了PHP中app\models\Users::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::validate方法的具体用法?PHP Users::validate怎么用?PHP Users::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::validate方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionCreate
/**
* Creates a new Users model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Users();
$model->setScenario('register');
$post = Yii::$app->request->post();
$formName = basename($model->className());
if ($model->load($post)) {
// Default value
$model->is_super_admin = isset($post[$formName]['is_super_admin']) ? $post[$formName]['is_super_admin'] : 0;
$model->role = $model->is_super_admin ? Identity::ROLE_SUPERADMIN : 30;
$model->fecha_conexion = isset($post[$formName]['fecha_conexion']) ? $post[$formName]['fecha_conexion'] : Yii::$app->fn->GetDate('none');
$model->fecha_modif = isset($post[$formName]['fecha_modif']) ? $post[$formName]['fecha_modif'] : Yii::$app->fn->GetDate('none');
$model->fecha_registro = isset($post[$formName]['fecha_registro']) ? $post[$formName]['fecha_registro'] : Yii::$app->fn->GetDate();
$model->id_estado = isset($post[$formName]['id_estado']) ? $post[$formName]['id_estado'] : 1;
if ($model->validate()) {
$model->setPassword();
$model->generateAuthKey();
if ($model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
}
}
}
// Load empty/error form
return $this->render('create', ['model' => $model]);
}
示例2: actionRegister
public function actionRegister()
{
$model = new Users();
$model->load(Yii::$app->request->post());
if ($model->validate()) {
$model->save();
return $this->render('confirm', ['model' => $model]);
}
return $this->render('register', ['model' => $model]);
}
示例3: actionIndex
public function actionIndex()
{
$model = new app\models\Users();
if ($model->load(Yii::$app->request->post())) {
if ($model->validate()) {
// form inputs are valid, do something here
return;
}
}
return $this->render('form1', ['model' => $model]);
}
示例4: actionRegister
public function actionRegister()
{
$model = new Users();
$result = ['model' => $model];
if (\Yii::$app->request->isPost) {
$post = \Yii::$app->request->post();
if ($model->load($post) && $model->validate()) {
echo '注册成功';
}
}
return $this->render('register', $result);
}
示例5: actionCreate
/**
* Creates a new Users model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Users();
if ($model->load(Yii::$app->request->post())) {
$model->username = $model->id;
$model->password = 'ltl333';
if ($model->validate()) {
$model->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
} else {
return $this->render('create', ['model' => $model]);
}
}
示例6: actionAdd
public function actionAdd($status = 3)
{
$user = new Users();
print $eng = Yii::$app->params['status_user_eng'][$status];
if ($status == '3') {
$users = Users::find()->select(['id', 'username'])->orderBy('username')->where(['status' => '2'])->all();
$items = ArrayHelper::map($users, 'id', 'username');
}
if (Yii::$app->request->post('Users')) {
$user->attributes = Yii::$app->request->post('Users');
if ($user->validate() && $user->save()) {
return $this->render($eng, ['model' => $user, 'items' => $items, 'status' => Yii::$app->params['status_user'][$status], 'ok' => 1]);
}
}
return $this->render($eng, ['model' => $user, 'items' => $items, 'status' => Yii::$app->params['status_user'][$status]]);
}