Search code examples
zend-frameworkdecoratorzend-decorators

zend decorator, adding an empty element before submit button


$submit->setDecorators(array('ViewHelper',

           array(array('data'=>'HtmlTag'), array('tag'=>'td', 'class'=>'element')),
           array(array('emptyrow'=>'HtmlTag'), array('tag'=>'td', 'class'=>'element')),
           array(array('row'=> 'HtmlTag'), array('tag'=>'tr'))
        ));

I want to get the following out put.

<tr><td class="element">&nbps;</td><td class="element">
<input type="submit" name="submit" id="submit" value="submit"></td></tr>

But as we know above code will wrap td around another td. like this

<tr><td class="element"><td class="element">
<input type="submit" name="submit" id="submit" value="submit"></td></td></tr>

I know that I can remove the emptyrow line entirly and use colspans as properties. but i don't want to go that why. I want to know how we can create a elment sibilling with other.


Solution

  • Try adding placement option to emptyrow

    $submit->setDecorators(array(
       'ViewHelper',
       array(array('data'=>'HtmlTag'), array('tag'=>'td', 'class'=>'element')),
       array(array('emptyrow'=>'HtmlTag'), array('placement' => Zend_Form_Decorator_Abstract::PREPEND, 'tag'=>'td', 'class'=>'element')),
       array(array('row'=> 'HtmlTag'), array('tag'=>'tr'))
    ));