-- Shaun Farrell <farrel...@gmail.com> wrote (on Wednesday, 01 April 2009, 07:20 PM -0400): > I am just starting to figure out Zend_Form_Decorators and have a question on > the best way to have Multiple buttons on one line all surround in one <div></ > div> > > Here is what I have and it works but I am wondering is this the best way to do > this?
Group them in a DisplayGroup. :) Really -- that's what display groups are for. Have your buttons simply do a ViewHelper decorator, and then have the display group do a FormElements and HtmlTag decorator: $form->addElement('submit', 'submit', array( 'label' => 'Submit Button', 'decorators' => array( 'ViewHelper', ), )); $form->addElement('submit', 'cancel', array( 'label' => 'Cancel Button', 'decorators' => array( 'ViewHelper', ), )); $form->addElement('submit', 'submit1', array( 'label' => 'Submit One Button', 'decorators' => array( 'ViewHelper', ), )); $form->addDisplayGroup(array('submit', 'cancel, 'submit1'), 'submitButtons', array( 'decorators' => array( 'FormElements', array('HtmlTag', array('tag' => 'div', 'class' => 'element')), ), )); The above will create create the buttons one after another, and then group them in a <div> with the class of "element". > I have three decorators > > // adds the <div to the first button > public $openButtonDecorators = array( > 'ViewHelper', > array('HtmlTag', array('tag' => 'div', 'class' => 'element', > 'openOnly' > =>true)) > ); > > // just outputs a button no decorator > public $noButtonDecorators = array( > 'ViewHelper', > ); > > //closes the div on the last button. > public $closeButtonDecorators = array( > 'ViewHelper', > array('HtmlTag', array('tag' => 'div', 'class' => 'element', > 'closeOnly'=>true)) > ); > > Then I take the buttons and add the decorators to them. > > $form->addElement('submit', 'submit', array( > 'Name'=> 'Submit Button', > 'decorators' => $this->openButtonDecorators, > )); > $form->addElement('reset', 'cancel', array( > 'Name'=> 'Cancel Button', > 'decorators' => $this->noButtonDecorators, > )); > $form->addElement('submit', 'submit1', array( > 'Name'=> 'Submit One Button', > 'decorators' => $this->closeButtonDecorators, > )); > > > Is this the best way to do this? -- Matthew Weier O'Phinney Software Architect | matt...@zend.com Zend Framework | http://framework.zend.com/