2011-11-23 36 views
0

我想知道如何風格Zend的形式:如何設置和格式化zend表單?

// Pants 
    $this->addElement('select', 'waistmin', array(
      'label' => 'Pants: ', 
      'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(21, 48), range(21, 48))), 
      'value' => 'Any' 
    )); 

    $this->addElement('select', 'waistmax', array(
      'label' => 'to: ', 
      'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(21, 48), range(21, 48))), 
      'value' => 'Any' 
    )); 

    // Bust & Chest 
    $this->addElement('select', 'bustmin', array(
      'label' => 'Bust & Chest: ', 
      'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(30, 50), range(30, 50))), 
      'value' => 'Any' 
    )); 

    $this->addElement('select', 'bustmax', array(
      'label' => 'to: ', 
      'multiOptions' => array_merge(array(''=>'', 'Any'=>'Any'),array_combine(range(30, 50), range(30, 50))), 
      'value' => 'Any' 
    )); 

我有這種形式在form.php的,我放在我的視圖文件使用echo $this->form;

我知道我可以添加樣式標籤和id標籤,但我想要它,所以定位它們更好。

現在他們來了一個後對方:

Pants: 
    <drip down> 
to: 
    <drip down> 
Bust & Chest: 
    <drip down> 
to: 
    <drip down> 

我想組一起的div或者也許在一個表:

Pants:    to: 
    <drip down>   <drip down> 

Bust & Chest:    to: 
    <drip down>   <drip down> 

如果我呼應的HTML表單,我們內部不在我的頁面內呈現。

關於我可以採取什麼方法的任何想法?

thans

+1

而不是echo'ing $ this-> form,請嘗試類似[this](http://stackoverflow.com/questions/7589603/using-viewscript-decorator-on-nested -subforms-zend-form/7590262#7590262)你將對你的表單的外觀和感覺擁有更多的控制權。 – drew010

+0

不錯,這可能工作。添加此作爲答案,並生病檢查它是最好的 – Patrioticcow

回答

1

如果你想有過如何以及在何處顯示單個表單元素,可以輸出單個表單元素更多的控制權,幷包起來的HTML,你認爲合適。

查看答案heresplitting up a zend form上的這個答案可能會幫助你,以及它顯示如何從select元素中移除裝飾器,所以它不會被包裝在任何可以很好地適用於下面的例子的html中。

而不是做你echo $this->form;可以做類似如下的:

<div class="form-sel"> 
Pants: <?php echo $this->form->waistmin ?> to: <?php echo $this->form->waistmax ?> 
</div> 

<div class="form-sel"> 
Bust &amp; Chest: <?php echo $this->form->bustmin ?> to: <?php echo $this->form->bustmax ?> 
</div> 
0

爲什麼不簡單地爲dl,dt和dd做Zend Forms的CSS使用。這將允許您修改它們的樣式