this is my controller code
public function actionRequest()
{
$model1 = new Password();
$model->scenario = 'request';
$this->performAjaxValidation($model1);
//echo "<pre>"; print_r($model1->scenarios()); var_dump($model1); exit;
if ($model1->load(Yii::$app->request->post()) && $model1->sendRecoveryMessage()) {
return $this->goBack();
} else {
return $this->render('login', [
'model' => $model,
]);
}
}
below is model code
public function attributeLabels()
{
return [
'email' => \Yii::t('app', 'Email'),
'password' => \Yii::t('app', 'Password'),
];
}
/** @inheritdoc */
public function scenarios()
{
return [
'request' => ['email'],
'reset' => ['password']
];
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['email'], 'required'],
['email', 'email'],
[['username'], 'string', 'max'=>200],
[['email'], 'string', 'max'=>200],
['password', 'validator'],
['confirmPassword', 'compare','compareAttribute'=>'newPassword', 'message'=>'Passwords not matching'],
];
}
and this code print_r($model1->scenarios()); giving me this
Array
(
[request] => Array
(
[0] => email
)
[reset] => Array
(
[0] => password
)
)
if i m using ajax validation without scenario it is working if i m using scenario then it is not working