Zend framework Zend框架:删除验证程序消息

Zend framework Zend框架:删除验证程序消息,zend-framework,Zend Framework,可能重复: 这是我的文件格式: $file = new Zend_Form_Element_File('file', array( 'required' => true, 'MaxFileSize' => 4194304, 'validators' => array( array('Count', false, 1),

可能重复:

这是我的文件格式:

$file = new Zend_Form_Element_File('file', array(
                'required' => true,
                'MaxFileSize' => 4194304,
                'validators' => array(
                    array('Count', false, 1),
                    array('Size', false, 4194304),
                    array('Extension', false, 'gif,jpg,png'),
                    array('ImageSize', false, array('minwidth' => 40,
                            'minheight' => 40,
                            'maxwidth' => 90,
                            'maxheight' => 90)))));

如何删除验证程序消息?

每个验证程序的最后一个参数可以是一个数组。可以传递的参数之一是“messages”,它是表示每个错误的特定于验证器的常量数组,以及错误消息字符串。通过查看验证器类(如Zend/Validate/File/ImageSize.php),可以获得错误代码列表。在您的情况下,这些将是:

$file = new Zend_Form_Element_File('file', array(
                'required' => false, //we will add this as a custom validator so we can over-ride the error message
                'MaxFileSize' => 4194304,
                'validators' => array(
                    array('NotEmpty', true, array('messages' => array('isEmpty' => "Your error message here")))
                    array('Count', false, array(count => 1, 'messages' => array('fileCountTooFew' => "Too few files, minimum '%min%' are expected but '%count%' are given", 'fileCountTooMany' => "Too many files, maximum '%max%' are allowed but '%count%' are given"))),
                    array('Size', false, array('size' => 4194304, 'messages'=> array('fileSizeTooBig' => "", 'fileSizeTooSmall' => "", 'fileSizeNotFound' => ""))),
                    array('Extension', false, array('extension' => 'gif,jpg,png', 'messages' => array('fileExtensionFalse' => "", 'fileExtensionNotFound' => ""))),
                    array('ImageSize', false, array('minwidth' => 40,
                            'minheight' => 40,
                            'maxwidth' => 90,
                            'maxheight' => 90,
                            'messages' => array(
                                'fileImageSizeWidthTooBig'   => "Maximum allowed width for image '%value%' should be '%maxwidth%' but '%width%' detected",
                                'fileImageSizeWidthTooSmall'  => "Minimum expected width for image '%value%' should be '%minwidth%' but '%width%' detected",
                                'fileImageSizeHeightTooBig'   => "Maximum allowed height for image '%value%' should be '%maxheight%' but '%height%' detected",
                                'fileImageSizeHeightTooSmall' => "Minimum expected height for image '%value%' should be '%minheight%' but '%height%' detected",
                                'fileImageSizeNotDetected'     => "The size of image '%value%' could not be detected",
                                'fileImageSizeNotReadable'     => "File '%value%' can not be read",
                            )
                        )
                    )
                )
            )
        );

你的意思是说,如果验证失败,如何删除消息?我不知道,文件验证程序的大小、扩展名、图像添加英文消息我需要删除它们。