当前位置: 首页>>代码示例>>PHP>>正文


PHP Users::validate方法代码示例

本文整理汇总了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]);
 }
开发者ID:juanchi008,项目名称:playa_auto,代码行数:30,代码来源:UsersController.php

示例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]);
 }
开发者ID:smackmybitchup,项目名称:yii2project,代码行数:10,代码来源:JopaController.php

示例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]);
 }
开发者ID:fran242,项目名称:Yii2-2,代码行数:11,代码来源:Form1Controller.php

示例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);
 }
开发者ID:xiaohongyang,项目名称:yii_shop,代码行数:12,代码来源:PublicController.php

示例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]);
     }
 }
开发者ID:PichurChill,项目名称:sues_print,代码行数:21,代码来源:UserController.php

示例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]]);
 }
开发者ID:pumi11,项目名称:aau,代码行数:16,代码来源:UserController.php


注:本文中的app\models\Users::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。