我有这个小问题,所以我使用zend装饰器将我的输入放在表中,但我需要在同一个tr中输入2个文本输入,并且我有超过2个。
我正在使用的代码
$title = new Zend_Form_Element_Text('title');
$title->setAttrib('size', '100');
$title->setLabel('Title')
->setAttrib('class', 'promoinputs');
$begindate = new Zend_Form_Element_Text('begindate');
$begindate->setLabel('Time')
->setAttrib('class', 'dateinputs');
$enddate = new Zend_Form_Element_Text('enddate');
$enddate->setLabel('to')
->setAttrib('class', 'dateinputs');
$radius = new Zend_Form_Element_Text('radius');
$radius->setLabel('Raduis')
->setAttrib('class', 'promoinputs');
$submit = new Zend_Form_Element_Submit('save');
$this->addElements(array($title, $begindate, $enddate, $radius, $submit));
$this->setElementDecorators(
array(
'ViewHelper',
array('Errors', array('data' => 'tr')),
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
array('Label', array('tag' => 'td', 'class' => 'promolabel')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr', 'class' => 'promotr')),
));
$submit->setDecorators(
array(
'ViewHelper',
array(array('data' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element')),
array(array('emptyrow' => 'HtmlTag'), array('tag' => 'td', 'class' => 'element', 'placement' => 'PREPEND')),
array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
));
$this->setDecorators(
array(
'FormElements',
array('HtmlTag', array('tag' => 'table', 'class' => 'promotable')),
'Form'
));
所以我需要把begindate和enddate放在同一个tr中,我怎么能这样做?
答案 0 :(得分:0)
使用子表格
$subform = new Zend_Form_SubForm();
$subform->addElement($text1)
->addElement($text2)
->setDecorators('FormElements',array('HtmlTag',array('tag'=>'tr')));
$form->addSubForm($subform,'my');