0

我在模型中有一些规则:

[['username', 'email', 'password', 'password_repeat'],'required', 'message' => 'Can not be blank'],
['username', 'string', 'min' => 2, 'max' => 255],
['password', 'string', 'min' => 6, 'max' => 255],

我设置了检查这些字段是否为空白的消息。但是我如何设置消息来检查输入长度。

我试过了:

['username', 'string', 'min' => 2, 'max' => 255, 'message' => 'too few characters'] 然而它似乎并不正确。

4

1 回答 1

1

您需要设置tooShort属性,http: //www.yiiframework.com/doc-2.0/yii-validators-stringvalidator.html# $tooShort-detail

['username', 'string', 'min' => 2, 'max' => 255, 'tooShort' => 'too few characters']
于 2016-04-11T15:37:02.047 回答