开发者

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

开发者 https://www.devze.com 2023-03-11 19:41 出处:网络
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 wan

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

0

精彩评论

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

关注公众号