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.开发者_StackOverflow中文版
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.
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
精彩评论