backend/controllers/AdminsController.php
/**
     * Creates a new Admins model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     * @return mixed
     */
Creates a new Admins model.
If creation is successful, the browser will be redirected to the 'view' page.
@return mixed
Creates a new Admins model . If creation is successful the browser will be redirected to the ' view ' page . @return mixed
public function actionCreate()
    {
        $model = new Admins();
        $password_model = new DynamicModel(['password', 'password_repeat']);
        $password_model
            ->addRule(['password', 'password_repeat'], 'required')
            ->addRule(['password'], 'string', ['min' => 6])
            ->addRule(['password'], 'match', ['pattern' => Users::PASSWORD_PATTERN, 'message' => "For the password you can use only letters of the Latin alphabet, digits and symbols !@#$%^&*()_+-=[]{}<>;:\"'\\|?/.,"])
            ->addRule(['password_repeat'], 'compare', ['compareAttribute' => 'password']);
        if ($password_model->load(Yii::$app->request->post()) && $password_model->validate()) {
            if ($model->load(Yii::$app->request->post())) {
                $model->setPassword($password_model->password);
                $model->generateAuthKey();
                if ($model->save()) {
                    return $this->redirect(['index']);
                }
            }
        }
        return $this->render('create', [
            'model'   => $model,
            'password_model' => $password_model,
            'current' => $this->Admins,
        ]);
    }
public function actionCreate ( ) { $ model = new Admins ( ) ; $ password_model = new DynamicModel ( [ 'password' , 'password_repeat' ] ) ; $ password_model -> addRule ( [ 'password' , 'password_repeat' ] , 'required' ) -> addRule ( [ 'password' ] , 'string' , [ 'min' => 6 ] ) -> addRule ( [ 'password' ] , 'match' , [ 'pattern' => Users :: PASSWORD_PATTERN , 'message' => " For the password you can use only letters of the Latin alphabet, digits and symbols !@#$%^&*()_+-=[]{}<>;: \" ' \\ |?/., " ] ) -> addRule ( [ 'password_repeat' ] , 'compare' , [ 'compareAttribute' => 'password' ] ) ; if ( $ password_model -> load ( Yii :: $ app -> request -> post ( ) ) && $ password_model -> validate ( ) ) { if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ model -> setPassword ( $ password_model -> password ) ; $ model -> generateAuthKey ( ) ; if ( $ model -> save ( ) ) { return $ this -> redirect ( [ 'index' ] ) ; } } } return $ this -> render ( 'create' , [ 'model' => $ model , 'password_model' => $ password_model , 'current' => $ this -> Admins , ] ) ; }
Creates a new Admins model.
Creates a new Admins model .