Applying Class to Customer Zend Decorator
I found code that would change the standard dt and dd tags to table tags for a Zend_Form_Element. Here is the code I used:
$element->setDecorators(array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
array('Label', array('tag' => 'td', 'class' => 'rightAlign')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
)); But this puts the class name 'rightAlign' on the label tag instead of the td. I can't seem to wra开发者_高级运维p my head around these custom decorators so can anyone tell me how to get the class name 'rightAlign' on the td surrounding the label?
Just add one more decorator
$element->setDecorators(array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
'Label',
array(array('labelWrap' => 'HtmlTag'), array('tag' => 'td', 'class' => 'rightAlign')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
));
$this->setElementDecorators(array(
'ViewHelper',
'Errors',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
array('Label',array('requiredSuffix' => ' * ')),
array(array('labelWrap' => 'HtmlTag'), array('tag' => 'td', 'align' => 'right')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
));
will add the required suffix ;)
精彩评论