Question

Hi I have created a setDecorator() which is something like this:

$timeSu->setDecorators(array('ViewHelper', 'Description', 'Errors',  
        array(
            array('data' => 'HtmlTag'),
            array('tag' => 'td', 'class' => 'input')),
        array('Label', 
            array('tag' => 'td')),  
        array(
            array('blah'=>'HtmlTag'),
            array('tag' => 'tr', 'openOnly' => true, 
                  'placement' => end_Form_Decorator_Abstract::PREPEND))

    ));

Similarly i have same decorator for more elements. Now this gives me something like

<form enctype="application/x-www-form-urlencoded" action="" method="post">
<div></div><div></div><div></div><div></div><div></div><table id="targetform"><tbody><tr><td id="timeSu-label"><label for="timeSu" class="required">Sunday:</label></td><td class="input"><select name="timeSu[]" id="timeSu" multiple="multiple" size="5" class="target_input"><option value="NULL" label="Select" selected="selected">Select</option><option value="00:00" label="00:00">00:00</option>.....</select></td><tr><td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="Submit" class="target_button"></td></tr></tbody></table></form>

and it creates two rows i.e. first row with the select element with two columns. first column contain the label name and second contain the select box. Now i have seven such select items and using above decorator for same it creates one row with 14 different colums. But what i want to do is to create a row that will contain 7 columns for 7 select elements. each column will than contain two rows, one for the label and second for select box.

In short currently the output shows each element attibutes like label and select in columns, and i want them to be in rows so that they would be like vertically aligned one below other. thanks.

Was it helpful?

Solution

Attach such decorator for each of your elements:

$this->addElement($this->createElement('select', 'fieldname1')
        ->setLabel('Label')
        ->setDecorators(array(
            'ViewHelper',
            array(array('filedtd' => 'HtmlTag'), array('tag' => 'td')),
            array(array('fieldtr' => 'HtmlTag'), array('tag' => 'tr')),
            'Label',
            array(array('labeltd' => 'HtmlTag'), array('tag' => 'td')),
            array(array('labertr' => 'HtmlTag'), array('tag' => 'tr')),
            array(array('table' => 'HtmlTag'),   array('tag' => 'table')),
            array(array('wholetd' => 'HtmlTag'), array('tag' => 'td')),
       )));

And decorator for form:

$this->setDecorators(array(
            'FormElements',
            'Form',
            array(array('wholerow' => 'HtmlTag'), array('tag' => 'tr')),
            array(array('table' => 'HtmlTag'),    array('tag' => 'table')),
        ));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top