blacktie24
blacktie24

Reputation: 5075

Zend Form: How can I show errors after the element's label tag?

I can get errors to be shown after the form element, but not directly after the form element's label tag. Does anyone know how I can do this?? Thx in advance! Cheers.

Upvotes: 1

Views: 982

Answers (2)

Phil
Phil

Reputation: 164764

If you want to place element errors between the element and its label, keeping the standard dt/dd markup, use something like this

$element->setDecorators(array(
    'ViewHelper',
    array('Errors', array('placement' => 'prepend')),
    array('HtmlTag', array('tag' => 'dd')),
    array('Label', array('tag' => 'dt'))
));

The important part is the 'placement' => 'prepend' on the Errors decorator.

Upvotes: 2

danielrsmith
danielrsmith

Reputation: 4060

I am pretty sure you can do this by altering the Decorator used to render the form elements.

Check here http://devzone.zend.com/article/3450

This article will guide you through creating alternate decorators for elements.

Also here is the Zend article on the standard decorators.

http://framework.zend.com/manual/en/zend.form.standardDecorators.html

Upvotes: 1

Related Questions