我无法确定以下Symfony 1.4表单验证中可能存在的错误。基本上,我只想让所有四个条件都得到正确考虑(必填、最小长度、最大长度、正则表达式)。它实际上是可行的,但对于“必填”条件,它未能显示我的自定义错误消息,而只是显示“必填”。有没有办法显示我的错误信息?
'username' => new sfValidatorAnd(array(
new sfValidatorString(
array('required' => true, 'min_length' => 4, 'max_length' => 20),
array('required' => 'Please enter a username.', 'min_length' => 'Your username must have at least 4 characters.', 'max_length' => 'Your username cannot be longer than 20 characters.')
),
new sfValidatorRegex(
array('pattern' => '/^[A-z0-9]*$/i'),
array('invalid' => 'Your username can only have letters (A-Z) or numbers (0-9).')
),
)),
还有一件事,如果我移除正则表达式验证器并将其转换为普通的单行字符串验证器,我的自定义错误消息就会显示出来了!?
有人知道原因吗?
提前感谢。