开发者

How to remove Zend Form error messages?

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>',
                'mar开发者_JS百科kupListItemEnd' => '</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
))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜