Yii2: Rules unicle vice versa



  • How do yii2 make a mistake if the value does not match the value from the database?

    I want to make a mistake if the user is not found in the database.

    Example of error if values match. What should be modified?

      public function rules()
        {
            return [
                ['user', 'unique', 'targetClass' => User::className(), 'message' => 'Имя пользователя уже занято'],
            ];
        }
    


  • I think your problem can be solved by exist
    Here's the reference to the Hyde in Russian: http://yiiframework.domain-na.me/doc/guide/2.0/ru/tutorial-core-validators#exist


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2