How to remove dd and dt html elements when rendering a Form element in ZF?
Asked Answered
F

2

12

I am rendering in my view a Zend_Form_Element_Select.

$t=new Zend_Form_Element_Select(....);
...
...
echo $t->render();

I get the drop down and the options correctly, but I also get the select element wrapped in

<dt> </dt>
<dd>[elm]</dd>

How do I remove that decorator?

Fabricant answered 8/5, 2009 at 3:12 Comment(0)
R
18

you have more possibilities: The relevant manual:

http://framework.zend.com/manual/en/zend.form.elements.html#zend.form.elements.decorators

second one is to remove decorators you don't need

$t->removeDecorator('Errors');
$t->removeDecorator('HtmlTag');
$t->removeDecorator('Label');

third one (probably the best one for you) is to set only decorators you need. Following code will set only view helper decorator, so there will be no label, no error message and no html tags

$t->setDecorators(array(
    array('ViewHelper'),
));

very good article about decorators is here:

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

Rappel answered 8/5, 2009 at 9:4 Comment(1)
I read. I tried $t->setDecorators(array('ViewHelper')); Missed one Array in the process and it drove me crazy.Fabricant
P
3

This did it for me:

$el->setDecorators(array( 'ViewHelper', 'Errors', 'Label'
));

Pettifogging answered 1/12, 2009 at 18:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.