2011-05-05 32 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