I believe compare is not the rule to check against, you should use exist rule or right a customer validate function to check if the email exists in the database
// please make sure to change the field/property name to match yours
public function rules()
{
return [
// other rules ...
['email', 'exist',
'targetClass' => 'app\models\User',
'message' => 'There is no user with this email address.'
]
];
}
Thank you for help but not work for me… i have yii 1.1+ version
I am rewrite your rule like
array( ‘email’, ‘exist’, ‘className’ => ‘Users’, ‘criteria’ => [‘condition’ => ‘Users::STATUS_ACTIVE’], ‘message’ => ‘There is no user with this email address.’, ‘on’ => ‘resetpassword’ )
1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘::STATUS_ACTIVE) AND (t.email=‘6g66@mail.ru’) LIMIT 1’ at line 1
Any way: I don’t think you need to quote the STATUS_ACTIVE condition
['condition' => Users::STATUS_ACTIVE],
In the Yii2 way in the rules of a requestPasswordReset model:
['email', 'exist',
'targetClass' => '\common\models\User',
'filter' => ['is_active' => Users::STATUS_ACTIVE],
'message' => Yii::t('app', 'There is no user with this email address.')
],