این و سوال قبلیم وابسته به همند
این ولیدیشن در create کار میکنه ولی در edit نه
این ولیدیشن در create کار میکنه ولی در edit نه
1 2 3 | [[ 'password' , 'password_repeat' ] , 'required' , 'on' => 'register' ], [ 'password_repeat' , 'compare' , 'compareAttribute' => 'password' , 'message' => 'رمز عبور و تکرار آن باید یکسان باشند' , 'on' =>[ 'register' , 'edit' ]], |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | public function actionCreate() { $model = new Users(); $model ->scenario = 'register' ; $model ->ts = time(); if ( $model ->load(Yii:: $app ->request->post())) { $model ->password_repeat = $model ->password; if ( $model ->save()) { $this ->redirect([ '/admin/users/index' ]); } else { throw new HttpException( '404' , 'خطا در ثبت نام کاربر جدید' ); } } return $this ->render( 'create' ,compact( 'model' )); } public function actionEdit( $id ) { $model = Users::findOne( $id ); if ( $model ->load(Yii:: $app ->request->post()) && $model ->save()) { $model ->scenario = 'edit' ; $this ->redirect([ '/admin/users/index' ]); } return $this ->render( 'edit' ,compact( 'model' )); } |
انگار که نیستی ، چو هستی خوش باش
حکیم عمر خیام
حکیم عمر خیام