如何删除Zend Form错误消息? [英] How to remove Zend Form error messages?
问题描述
私人函数_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'
));
或者当您添加元素时: I have changed decorator: 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: 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: Or when you are adding the element:
这篇关于如何删除Zend Form错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
< pre $ $ form-> addElement($ type,$ name,array(
'decorators'=> $ decorators
))
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;
}
$form->setElementDecorators(array(
'ViewHelper',
'HtmlTag',
'Label'
));
$element->setDecorators(array(
'ViewHelper',
'HtmlTag',
'Label'
));
$form->addElement($type, $name, array(
'decorators' => $decorators
))