views:

100

answers:

1

I have the Zend Form with some elements. And I need to placing some elements in first div, some in other div. Part of my form:

private function _createForm($action) {

$form = new Zend_Form();

$form->setName($action . '_form');
$form->setMethod('post');       

$title = $form->createElement('text', 'title');
$title->setLabel('Title')
      ->setAttrib('maxlength',50)->setAttrib('id', 'title')->setAttrib('class', $action . '_title')
      ->setAttrib('style','height: 15px; width: 200px;')
      ->setRequired(true)
      ->setDecorators(array(
        'ViewHelper',
        array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class'  => 'element')),
        array('Label', array('tag' => 'td')),
        array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
      ));
$priority = $form->createElement('select', 'priority');
$priority->setLabel('Parent Rank')
        ->setAttrib('id', 'priority')->setAttrib('class', $action . '_priority')
        ->setMultiOptions($dataGrid->AllRanks())
        ->setDecorators(array(
          'ViewHelper',
          array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class'  => 'element')),
          array('Label', array('tag' => 'td')),
          array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
        ));
$enabled = $form->createElement('select', 'enabled');
$enabled->setLabel('Enabled')
        ->setAttrib('id', 'enabled')->setAttrib('class', $action . '_enabled')
        ->setMultiOptions(array('1'=>'yes', '0'=>'no'))
        ->setDecorators(array(
          'ViewHelper',
          array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class'  => 'element')),
          array('Label', array('tag' => 'td')),
          array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
        ));
$use_gv = $form->createElement('select', 'use_gv');
$use_gv->setLabel('Use GV in calc.?')
        ->setAttrib('id', 'use_gv')->setAttrib('class', $action . '_use_gv')
        ->setMultiOptions(array('1'=>'yes', '0'=>'no'))
        ->setDecorators(array(
          'ViewHelper',
          array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class'  => 'element')),
          array('Label', array('tag' => 'td')),
          array(array('row' => 'HtmlTag'), array('tag' => 'tr')),
        ));   

}

And now, how to placing $title and $priority elements in one div, and others elements in the seconf?

+1  A: 

You need to use display groups (http://framework.zend.com/manual/en/zend.form.forms.html#zend.form.forms.displaygroups). Disable the default decorators for them and then add your own using the the setDecorator function

Ashley