在我的Zend表单中添加装饰器后,它有一些不需要的
喜欢 - >
<dt id="step1-label"> </dt>
我的问题是,我在我的phtml中添加了一个div后的表单。 div和form之间有一个空格,我无法移除那个空间,你能帮帮我吗?
我的完整表格是
class Admin_Form_RatesForm extends Zend_Form
{
/**
* Form's set values and multy options
* @var array
*/
private $options;
/**
* Initailise options arrays
* @param $options
*/
public function __construct($options = null)
{
if(isset($options)){
$this->options = $options;
}
parent::__construct();
$this->setMethod('post');
}
/**
* Set form elements
* Add elements to display groups
*/
public function init(){
//intalise to local varible
$options = $this->options;
//show room type selector
$roomTypes = new Zend_Form_Element_Select('room_types');
$roomTypes->setLabel('Room Type :');
$roomTypes->addMultiOption('All', 'ALL');
$roomTypes->addMultiOptions($options['room_types']);
$roomTypes->setDecorators(
array(
'ViewHelper',
'Description',
'Errors',
array('Label',
array(
'class' => 'label' , 'class' => 'margin-bot20'
)
),
array('HtmlTag',
array('tag' => 'div', 'class' => 'floatleft margin-bot20')
),
array(
array('td' => 'HtmlTag'), array('tag' => 'td')
)
)
);
//show offers selector
$offers = new Zend_Form_Element_Select('offers');
$offers->setLabel('Offer :');
$offers->addMultiOptions($options['offers']);
$offers->setDecorators(
array(
'ViewHelper',
'Description',
'Errors',
array('Label',
array(
'class' => 'label' , 'class' => 'margin-bot20'
)
),
array('HtmlTag',
array('tag' => 'div', 'class' => 'floatleft margin-bot20')
),
array(
array('td' => 'HtmlTag'), array('tag' => 'td')
)
)
);
//insert button
$insert = new Zend_Form_Element_Button('insert');
$insert->setLabel('Insert Rates');
$insert->setDecorators(
array(
'ViewHelper',
'Description',
'Errors',
array('Label',
array(
'class' => 'label' , 'class' => 'margin-bot20'
)
),
array('HtmlTag',
array('tag' => 'div', 'class' => 'floatright margin-bot20')
),
array(
array('td' => 'HtmlTag'), array('tag' => 'td')
)
)
);
//make date picker using js
$fromDate = new Zend_Form_Element_Text('from_date');
$fromDate->setLabel("Valid from : ");
//make date picker using js
$toDate = new Zend_Form_Element_Text('to_date');
$toDate->setLabel('to :');
//make radio buttons
//show display groups according to click redio button
$type = new Zend_Form_Element_Radio('type');
$type->setLabel('Type');
$type->addMultiOption('per', 'Percentage');
$type->addMultiOption('fix','Fixed');
//use for set presetage rate
$percent = new Zend_Form_Element_Text('percent');
$percent->setLabel($options['precent_lable']);
$percent->class = 'number';
//make grid form for set fixed values
$fixed = new Zend_Form_Element_Hidden('fixed');
$fixed->setDecorators(
array(
array(
'ViewScript',
array(
'viewScript' => 'customviewscripts/_fixedgrid.phtml',
'meal_plans' => $options['meal_plans'],
'room_types' => $options['room_types']
)
)
)
);
//submit button
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit For Approval');
$submit->class="submit";
//show default form
$this->addElements(
array(
$roomTypes,
$offers,
$insert
)
);
$step1 = $this->addDisplayGroup(
array(
'room_types',
'offers',
'insert'
), 'step1',
array('dtLabel' => '')
);
//show after click insert button
$this->addElements(
array(
$fromDate,
$toDate,
$type,
$percent,
$fixed,
$submit
)
);
$step2 = $this->addDisplayGroup(
array(
'from_date',
'to_date',
'type',
'percent',
'fixed',
'submit'
), 'step2',
array('dtLabel' => '')
);
}
}
答案 0 :(得分:1)
这是由于显示组上的DtDdWrapper装饰器,特别是此代码
$dtLabel = $this->getOption('dtLabel');
if( null === $dtLabel ) {
dtLabel = ' ';
}
尝试在显示组上设置此选项,例如
$step1 = $this->addDisplayGroup(
array(
'room_types',
'offers',
'insert'
), 'step1',
array('dtLabel' => '')
);
我必须说,我从来没有喜欢过DtDdWrapper,老实说也无法理解为什么Zend选择默认为止。随意查看我的Zend Form扩展,完成默认的装饰器大修