Validation Yii2显示验证提示
我可以在验证期间在yii2中显示提示吗? 在我的模型中,我有:Validation Yii2显示验证提示,validation,yii2,hint,Validation,Yii2,Hint,我可以在验证期间在yii2中显示提示吗? 在我的模型中,我有: public function rules() { return [ [['content'], 'checkLastCommentDate', 'skipOnEmpty' => false, 'skipOnError' => false], ]; } public function check
public function rules()
{
return [
[['content'], 'checkLastCommentDate', 'skipOnEmpty' => false, 'skipOnError' => false],
];
}
public function checkLastCommentDate($attribute)
{
if (true) {
//can set hint here?
}
}
使用Model::addError方法:
public function checkLastCommentDate($attribute)
{
if (true) {
$this->addError($attribute, 'Here is my hint');
}
}
不,yii2有一些类似提示的东西,但我不能在验证中使用它。也许它不应该在验证中?我只想在$vat==5时显示提示