I am trying to check the uniqueness of the field case-insensitively as follows:
public function rules() { return [ ['model_field', 'unique', 'on' => 'organization', 'targetClass' => '\common\models\ModelClass', 'targetAttribute' => 'lower(bd_field)', 'attributes' => 'lower_model_field', } ], ]; } Where:
- model_field is the model field that I want to test;
- bd_field is a field in the database from the \ common \ models \ ModelClass model that I want to compare with to check for uniqueness, case-insensitive;
- lower_model_field is a field in the current model, which is equal to the lower case field of model_field
Friends, help me figure out what I'm doing wrong, because it doesn't work.