2011-03-25 71 views
0

我有窗體,我想在一個div中添加幾個元素。但是我犯了一個錯誤。有人能幫我嗎。這裏是我的代碼:如何在一個div中追加兩個元素?

class Application_Form_Register extends Zend_Form 
{ 
    public function init() 
    { 
     $this->addElement('text', 'a', array(
      'label' => 'aa', 
      'required' => true, 
     )); 
     $this->addElement('text', 'b', array(
      'label' => 'bb', 
      'required' => true, 
     )); 
     $this->addElement('text', 'c', array(
      'label' => 'cc', 
      'required' => true, 
     )); 
     $this->addElement('text', 'd', array(
      'label' => 'dd', 
      'required' => true, 
     )); 
     $this->addElement('text', 'e', array(
      'label' => 'ee', 
      'required' => true, 
     )); 

     $this->getElement('c')->addDecorator('HtmlTag', array('tag' => 'div', 'openOnly' => 'true', 'placement' => Zend_Form_Decorator_Abstract::PREPEND,)); 
     $this->getElement('d')->addDecorator('HtmlTag', array('tag' => 'div', 'closeOnly' => 'true',)); 
    } 
} 

然後我呈現形式,我得到的HTML類似:

<form enctype="application/x-www-form-urlencoded" action="" method="post"> 
<dl class="zend_form"> 
<dt id="a-label"><label for="a" class="required">aa</label></dt> 

<dd id="a-element"> 
<input type="text" name="a" id="a" value="" /></dd> 
<dt id="b-label"><label for="b" class="required">bb</label></dt> 
<dd id="b-element"> 
<input type="text" name="b" id="b" value="" /></dd> 
<dt id="c-label"><label for="c" class="required">cc</label></dt> 

<div> 

<input type="text" name="c" id="c" value="" /> 
<dt id="d-label"><label for="d" class="required">dd</label></dt> 

<input type="text" name="d" id="d" value="" /> 

</div> 

<dt id="e-label"><label for="e" class="required">ee</label></dt> 

我設置decoratos設置DIV附上çd元素,但我得到封閉DC輸入但不是C標籤

Ho在線前獲得DIV:

<dt id="c-label"><label for="c" class="required">cc</label></dt> 
+0

1.我不知道你的問題是什麼 - 也許換句話說吧。 #2.它應該是「需要」而不是「重新調整」 – halfdan 2011-03-25 14:15:54

+0

我的錯誤我修復它的問題 – Liutas 2011-03-25 14:24:28

回答

1

用於更改您的Html輸出我會嘗試使用一些使用不同視圖助手的自定義窗體元素對象。在ehivh中,你可以很容易地定義輸出應該是什麼樣的,例如標籤的放置和包裝以及元素的所有其他子部分。

相關問題