Hi,
I’ve just installed Yii2 advanced template, and still learning - haven’t produced any useful code yet.
When a user signs up from the signup page of the advanced template, the email address is checked by the Unique validator:
['UserEmail', 'trim'], ['UserEmail', 'required'], ['UserEmail', 'email'], ['UserEmail', 'string', 'max' => 255], ['UserEmail', 'unique', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.']
However, it does not do enough, and so I want to add code to UniqueValidator.php to support this:
['UserEmail', 'unique', 'case' => 'lower', 'targetClass' => '\common\models\User', 'message' => 'This email address has already been taken.'],
I was hoping someone could point out how to make the changes - where to find the array of properties so I can add the new ‘case’ property with allowed values of lower or any (any must be the default, so the behaviour remains unchanged if the case property is not used and also how to ensure the sql I use will work on most databases.
The reason for the changes is that email addresses like "FirstMiddleLast@EmailAddress.com" can be left in the database as the user prefers it, but the unique check is done using only lowercase, so that "Firstmiddlelast@EmailAddress.com" is picked up as a duplicate email address.
Best Regards,
Richard.