Answer the question
In order to leave comments, you need to log in
[[+content_image]]
Doesn't throw an error for validation in Yii2?
Validation code:
public $contact;
public function rules()
{
return [
[['contact'], 'required', 'message' => Yii::t('app', 'The field does not have to be empty!')],
[['contact'], 'string', 'min' => 4, 'message' => Yii::t('app', 'Contact should contain at least 4 characters.')],
];
}
[['contact'], 'string', 'min' => 4, 'message' => Yii::t('app', 'Contact should contain at least 4 characters.')],
Answer the question
In order to leave comments, you need to log in
Found a solution, for the error message when there is 'min' => 4, 'tooShort' => "message error" displays an error, not 'message', well, for 'max' => 50 then 'tooLong' => "message error".
Good evening.
Do you have such a line in the translation file?
Show translation file.
ps
In your translation file, in the returned array, there should be the following line:
And then in the validation rules, you can use it like this:'message' => Yii::t('app', 'MIN_ERROR')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question