public function actionUser() { $model = new UserForm(); if ($model->load(Yii::$app->request->post()) && $model->valideate()) { } else { return $this->render('userForm', ['model' => $model]); } }
public function actionUserForm() { $model = new UserForm(); if ($model->load(yii::$app->request->post()) && $model->validate()) { // alguma coisa } else { return $this->render('userForm', array('model' => $model)); } }
public function actionEdit() { $request = Yii::$app->request; $user = User::findOne($request->get('id')); $model = new UserForm(); $model->attributes = $user->attributes; if ($model->load($request->post()) && $model->validate()) { //Overall assignment the attributes of $user must be safe attributes $user->attributes = $model->attributes; // var_dump($model->attributes); // var_dump($user->attributes);exit(); if ($user->save()) { $this->redirect(array('index')); } else { } } else { if ($model->hasErrors()) { // foreach($model->getErrors() as $error){ // var_dump($error,false); // } } } return $this->render('edit', ['model' => $model]); }