如何删除Zend Form错误消息? [英] How to remove Zend Form error messages?

查看:135
本文介绍了如何删除Zend Form错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



 私人函数_addErrorDecorator($ form)
{
$ form - > setDecorators(array(
'FormElements',
new Zend_Form_Decorator_FormErrors(array

'ignoreSubForms'=> true,$ b $'markupElementLabelEnd'=> '< / b>',
'markupElementLabelStart'=>'< b>',
'markupListEnd'=>'< / div>',
'markupListItemEnd' =>'< / span>',
'markupListItemStart'=>'< span>',
'markupListStart'=>'< div id =Form_Errors>'

),
'表'
));
返回$ form;
}

但是现在我需要删除表单域下的错误消息。我怎样才能做到这一点?

解决方案

表单中的每个元素,子表单和显示组都有一个装饰器堆栈,将需要修改您希望不显示错误消息的元素的堆栈。



有很多方法可以做到这一点:

  $ form-> setElementDecorators(array(
'ViewHelper',$ b $'HtmlTag',
'Label'
));

如果您想保留默认元素装饰器堆栈,但使用错误装饰器除去。您也可以在个别元素的基础上做到这一点:

  $ element-> setDecorators(array(
'ViewHelper ',
'HtmlTag',
'Label'
));

或者当您添加元素时:

< pre $ $ form-> addElement($ type,$ name,array(
'decorators'=> $ decorators
))


I have changed decorator:

private function _addErrorDecorator($form)
{
    $form->setDecorators(array(
        'FormElements',
        new Zend_Form_Decorator_FormErrors(array
            (
                'ignoreSubForms' => true,
                'markupElementLabelEnd' => '</b>',
                'markupElementLabelStart' => '<b>',
                'markupListEnd' => '</div>',
                'markupListItemEnd' => '</span>',
                'markupListItemStart' => '<span>',
                'markupListStart' => '<div id="Form_Errors">'
            )
        ),
        'Form'
    )); 
    return $form;
}

But now i need to remove error messages under form fields. How do i make it?

解决方案

Each element, subform and display group in your form has a decorator stack as well, so you will need to modify the stack for the elements you want to not display the error messages.

There's a lot of ways to do this:

$form->setElementDecorators(array(
    'ViewHelper',
    'HtmlTag',
    'Label'
));

Is the way to go if you want to keep the default element decorator stack, but with the error decorator removed. You can also do it on an individual element basis:

$element->setDecorators(array(
    'ViewHelper',
    'HtmlTag',
    'Label'
));

Or when you are adding the element:

$form->addElement($type, $name, array(
    'decorators' => $decorators
))

这篇关于如何删除Zend Form错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆