Here's one way to do it:
<?php
class Core_Form_Test extends Zend_Form
{
public function init()
{
$row = array(
'Label',
array(array('labelTd'=>'HtmlTag'),
array('tag'=>'td', 'class'=>'label')),
array(array('elemTdOpen'=>'HtmlTag'),
array('tag'=>'td', 'openOnly'=>true,
'placement'=>'append')),
'ViewHelper',
'Errors',
array(array('elemTdClose'=>'HtmlTag'),
array('tag'=>'td', 'closeOnly'=>true,
'placement'=>'append')),
array(array('row'=>'HtmlTag'), array('tag'=>'tr'))
);
$table = array(
'FormElements',
array('HtmlTag', array('tag'=>'table')),
'Form'
);
$this->addElement('text', 'foo',
array('label'=>'First', 'decorators' => $row))
->addElement('text', 'bar',
array('label'=>'Second','decorators' => $row))
->addElement('text', 'baz',
array('label'=>'Third', 'decorators' => $row))
->addElement('text', 'quux',
array('label'=>'Fourth','decorators' => $row))
->setDecorators($table);
}
public function render(Zend_View_Interface $view=null)
{
$elems = $this->getElements();
$count = 0;
foreach ($elems as $elem) {
$elem->getDecorator('row')
->setOption('class', ++$count % 2 == 0 ? 'even' : 'odd');
}
return parent::render($view);
}
}
Then just use CSS to style the TDs.
On Tue, Nov 11, 2008 at 9:17 AM, DorkFest <[EMAIL PROTECTED]> wrote:
>
> Anyone have any simple strategies for providing alternative row CSS classes
> (eg: "odd-row", "even-row") in a Zend_Form?
>
> Thanks!
> --
> View this message in context:
> http://www.nabble.com/Alternating-row-colors-in-a-Zend_Form-tp20431687p20431687.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>
--
-- Mon