2013-04-23 30 views
0

任務是使用裝飾或東西 現在我有如何更換標籤標籤Zend的形式

<label for="field1" class="required">Field1</label> 
<input type="text" name="field1" id="field1" value="" size="20"> 

我想要什麼被任何人取代了Zend形式標籤標籤(即格)有

<div>Field1</div> 
<input type="text" name="field1" id="field1" value="" size="20"> 

這可能嗎?怎麼做?

+1

哪個版本您正在ZF的? – 2013-04-23 10:31:57

+0

我正在使用v1.12 – setrul 2013-04-23 10:36:51

+0

chandresh_cool的答案應該可以工作。請你可以編輯你的問題,包括你的裝飾器代碼基於這個答案,它正在生產的HTML – 2013-04-23 11:41:31

回答

1

事端這樣

$this->setElementDecorators(array(
array('ViewHelper'), 
array('Errors', array('tag' => 'div', 'class' => 'error')), 
array('Label', array('tag' => 'span')), 
array('HtmlTag', array('tag' => 'div', 'class' => 'label')), 

));

更多參考訪問此link

+1

不,它只是將標籤標籤放置在跨度內,但我需要更換標籤標籤。 – setrul 2013-04-23 10:42:35

0

不知道這是否是可能的標籤,我想你將不得不重寫標籤元素是如何的形式呈現。我只是設法以相同的使用說明標籤:

<div class="input-group input-group-sm col-md-12"> 
    <span class="input-group-addon">Name of the field</span> 
    <input id="name" class="form-control" type="text" name="name"> 
</div> 

這是通過使用裝飾像做:

public $inputDecorators_md12 = array(
     'ViewHelper',   
     array('Description', array('escape' => false, 'tag' => 'span', 'placement' => 'prepend', 'class'=>'input-group-addon')), 
     array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'input-group input-group-sm col-md-12')) 
    ); 

請注意,您可以定義要用於描述任何類型的標籤。

所以不是

$field->setLabel('fieldlabel') 

你可以這樣做:

$field->setDescription('fieldlabel') 
     ->setDecorators($this->inputDecorators_md12);