2012-07-03 48 views
0

我有一個Zend形式和我需要的廣電集團的最終輸出HTML是這樣的:如何在Zend框架的單選按鈕的輸入標題申請裝飾

<div> 
    <span class='radio_title'>Gender</span> <!-- The issue is in this line --> 
    <span class='felement'> 
      <label ....> <input type="radio" ...... value="male" /></label> 
      <label ....> <input type="radio" ...... value="female" /></label> 
    </span> 
</div> 

(即)更換默認dt和DD定製的div或span標籤

我創建了一個裝飾如下:

$decorator = array(
'ViewHelper', 
'Errors', 
    array(array('data' => 'HtmlTag'), array('tag' => 'span', 'class'=> 'felement')), 
    // the next line is never applied 
    array('Label', array('tag' => 'span', 'class'=> 'fradio' , 'placement'=>'prepend')), 
    array(array('row' => 'HtmlTag'), array('tag' => "div")) 
); 

$gender = new Zend_Form_Element_Radio("gender", 
     array(
       "label"=>"Gender", 
       'multiOptions'=>array(
       'male'=>'Male', 
       'female'=>'Female' 
      ), 
      "decorators"=>$decorator 
)); 

,我得到這個輸出,而不是:

<dt id="gender-label"> 
     <label class="optional">Gender</label> 
</dt> 
<!-- i don't know why the Main Label of the radio group didn't 
have the Label decorator applied to it --> 
<div>  
    <span class="felement"> 
    <label for="gender-male"><input type="radio" disablefor="1" checked="checked" value="male" id="gender-male" name="gender">Male</label> 
     <label for="gender-female"><input type="radio" disablefor="1" value="female" id="gender-female" name="gender">Female</label>  
    </span> 
</div> 

回答

1

我申請這個裝飾:

array(
      'ViewHelper', 
      'Errors',    
       array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class'=> 'fradioelement')), 
       array('Label', array('tag' => 'span', 'class'=> 'fradiotitle')), 
       array('description', array('tag' => 'span')), 
       array(array('row' => 'HtmlTag'), array('tag' => "div","class"=>"radioelement")) 

      ); 

它給了我這樣的輸出:

<div class="radioelement"> 
    <span id="gender-label"><label class="fradiotitle optional" for="gender">Gender</label></span> 
    <div class="fradioelement"> 
      <label for="gender-male"><input type="radio" checked="checked" value="male" id="gender-male" name="gender">Male</label> 
      <label for="gender-female"><input type="radio" value="female" id="gender-female" name="gender">Female</label> 
    </div> 
</div> 

這是我需要什麼差不多。

**我不得不添加:

'disableLoadDefaultDecorators' => true 
在元素的選項