اعتبار سنجی

ساخت وبلاگ
این و سوال قبلیم وابسته به همند
این ولیدیشن در create کار میکنه ولی در edit نه
[['password','password_repeat'] , 'required' , 'on'=> 'register'], ['password_repeat','compare','compareAttribute'=> 'password','message'=>'رمز عبور و تکرار آن باید یکسان باشند','on'=>['register','edit']],
 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','خطا در ثبت نام کاربر جدید');
}
}
retu $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']);
}
retu $this->render('edit',compact('model'));
}

برنامه نویس...
ما را در سایت برنامه نویس دنبال می کنید

برچسب : نویسنده : خنجی prog بازدید : 150 تاريخ : چهارشنبه 11 فروردين 1395 ساعت: 19:58

خبرنامه