views:

368

answers:

1

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?

+4  A: 

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
))
Johrn
Thanks and how to display all error messages beyond the form? Currenly they are below. I could fix this via css, but this isn't right. :)
Beck
I mean, how to set something like setPosition for all errors or er even error wrapper. I have found only getPosition. And have found, that there are only two options Prepend and Append, but how to set them i haven't found.
Beck
You could try adding 'position' => 'append' to your `new Zend_Form_Decorator_FormErrors` array.
Johrn
Yea did it, thanks. :)
Beck