2011-05-05 51 views
1

后,我加装饰我的Zend的形式,它有一些不必要的 如何删除不需要的 由Zend的形式产生

像 - >

<dt id="step1-label">&nbsp;</dt> 

我的问题是,我将我的表格后, div在我的phtml。 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

它通常最好不要覆盖的形式构造。无论如何,默认方法是'post' – Phil 2011-05-05 04:29:17

+0

我认为在添加显示组时会生成空格 – 2011-05-05 04:36:10

+1

编辑问题时,请确保选择整个代码块并按CTRL + K或花括号图标'{} '将它包装在代码块中 – JohnP 2011-05-05 05:16:53

回答

1

这是由于您的显示组的DtDdWrapper装饰,特别是这段代码

$dtLabel = $this->getOption('dtLabel'); 
if(null === $dtLabel) { 
    dtLabel = '&#160;'; 
} 

尝试设置您的显示组此选项,例如

$step1 = $this->addDisplayGroup(
     array(
      'room_types', 
      'offers', 
      'insert' 
     ), 'step1', 
     array('dtLabel' => '') 
    ); 

我必须说,我从来不喜欢DtDdWrapper,并且坦白地说不明白为什么Zend选择这种默认方式。随时检查出我的Zend的形式延伸,完成总默认装饰检修

+0

向disply组添加数组('dtLabel'=>')但没有奏效。 – 2011-05-05 04:46:02

+0

@tittletipz你能用更新的代码编辑你的问题吗? – Phil 2011-05-05 04:58:59

+0

我编辑它phil。请检查一下 ........... – 2011-05-05 05:13:43