How do I remove unwanted generated by Zend Form
After I added decorators to my Zend Form it has some unwanted
like ->
<dt id="step1-label"> </dt>
My problem is, I added my form after a div in my phtml. There is a space between the div and form, I can't remove that space, can you please help me?
My complete form is
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' => '')
);
}
}
This is due to the DtDdWrapper decorator on your display group, specifically this code
$dtLabel = $this->getOption('dtLabel');
if( null === $dtLabel ) {
dtLabel = ' ';
}
Try setting this option on your display group, eg
$step1 = $this->addDisplayGroup(
array(
'room_types',
'offers',
'insert'
), 'step1',
array('dtLabel' => '')
);
I must say, I've never liked the DtDdWrapper and honestly can't understand why Zend opted for that as default. Feel free to check out my Zend Form extension, complete with total default decorator overhaul
- Form
- Elements, decorators, etc
精彩评论