My controller:
public function rules()
{
return [
[['text'], 'required', 'message' => 'Fill in this field'],
['text', 'string', 'min' => 6, 'message' => 'Too short message'],
['text', 'validateUser']
];
}
public function validateUser($attribute)
{
if (Yii::$app->user->isGuest)
$this->addError($attribute, 'You must be logged in');
}
I have 2 problems:
1) Instead of the message 'Too short message' i see 'text field should contain at least 6 characters.'
2) validateUser not added a warning 'You must be logged in'