Ric*_*ing 6 zend-framework zend-form-element
我正在尝试将自己的自定义错误消息设置到我的Captcha上,但由于某种原因它会回显两次.
这是我的验证码:
$captcha = new Zend_Form_Element_Captcha(
'captcha', // This is the name of the input field
array('captcha' => array(
// First the type...
'captcha' => 'Image',
// Length of the word...
'wordLen' => 6,
// Captcha timeout, 5 mins
'timeout' => 300,
// What font to use...
'font' => 'images/captcha/font/arial.ttf',
// URL to the images
'imgUrl' => '/images/captcha',
//alt tag to keep SEO guys happy
'imgAlt' => "Captcha Image - Please verify you're human"
)));
Run Code Online (Sandbox Code Playgroud)
然后设置我自己的错误消息:
$captcha->setErrorMessages(array('badCaptcha' => 'My message here'));
Run Code Online (Sandbox Code Playgroud)
验证失败后,我得到:
'My message here; My message here'
Run Code Online (Sandbox Code Playgroud)
为什么重复错误以及如何解决?
Ric*_*ing 14
在花了很多时间试图让它工作之后,我最终在构造函数的选项中设置了消息
$captcha = new Zend_Form_Element_Captcha(
'captcha', // This is the name of the input field
array(
'captcha' => array(
// First the type...
'captcha' => 'Image',
// Length of the word...
'wordLen' => 6,
// Captcha timeout, 5 mins
'timeout' => 300,
// What font to use...
'font' => 'images/captcha/font/arial.ttf',
// URL to the images
'imgUrl' => '/images/captcha',
//alt tag to keep SEO guys happy
'imgAlt' => "Captcha Image - Please verify you're human",
//error message
'messages' => array(
'badCaptcha' => 'You have entered an invalid value for the captcha'
)
)
)
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7628 次 |
| 最近记录: |