覆盖Zend验证消息

时间:2012-06-24 06:16:47

标签: zend-framework zend-form-element

如何在下面的代码中覆盖Zend验证消息。

$validatee = array(
                        'email' => $email,
                );
        $validator = array(
                    'email' => array(
                                'EmailAddress',
                                'messages' => array('emailAddressInvalidFormat',"Invalid Email Address")
                            )
                    );

        $emailValidator = new Zend_Filter_Input(null, $validator,$validatee);

我尝试过这样做,但消息没有改变,总是输出

"no valid email address in the basic format local-part@hostname"

请帮忙!

1 个答案:

答案 0 :(得分:0)

将$ validator更改为::

       can you try adding 
$validator = new Zend_Validate_EmailAddress();
$validator->setMessage(
    'A valid email is required',
    Zend_Validate_EmailAddress::INVALID
); 

and then use in Zend_filter_input?