2012-06-26 2 views
0

Я хочу, чтобы объединить два элемента с сНом тегом, я хочу, чтобы как этогоинкапсулировать два элемента в пределах сНу

<div> 
    <span id="mailRecepientName2-label"> 
     <label class="elementTitle required" for="mailRecepientName2">اسم المستفيد</label> 
    </span> 
    <span> 
     <input id="mailRecepientName2" type="text" value="" name="mailRecepientName2"> 
    </span> 
    <span id="mailRecepientNote2-label"> 
     <label class="required" for="mailRecepientNote2">البيـــــــان</label> 
    </span> 
    <span class="largeText"> 
     <input id="mailRecepientNote2" type="text" value="" name="mailRecepientNote2"> 
    </span> 
    <a class="ico_lable_remove" data-recepeintcount="2" name="deleteNewRecepient" href="javascript:void(0)"></a> 
</div> 

я сделать так,

$mailRecepientName = new Zend_Form_Element_Text("mailRecepientName" . $id); 
    $mailRecepientName->setRequired(true)->setLabel('اسم المستفيد')->setDecorators(array(
      'ViewHelper', 
      'Errors', 
      array(array('data' => 'HtmlTag'), array('tag' => 'span')), 
      array('Label', array('tag' => 'span')) 
     );); 

    $mailRecepientNote = new Zend_Form_Element_Text("mailRecepientNote" . $id); 
    $mailRecepientNote->setRequired(true)->setLabel('البيـــــــان')->setDecorators(array(
      'ViewHelper', 
      'Errors', 
      array(array('data' => 'HtmlTag'), array('tag' => 'span')), 
      array('Label', array('tag' => 'span')) 
     );); 
    ); 

оба этих элементы принадлежит той же группы полей. Как я могу сделать их ecncapsulated внутри div?

ответ

0

Вы могли бы попытаться создать свои собственные элементы формы для сНа открытого и сНа закрытия:

MyApp/Форма/элемент/Divopen.php

require_once 'Zend/Form/Element/Xthml.php'; 
class MyApp_Form_Element_Divopen extends Zend_Form_Element_Xhtml { 

public $helper = 'formDivopen'; 
} 

MyApp/Форма/Элемент/Divclose.php

require_once 'Zend/Form/Element/Xthml.php'; 
class MyApp_Form_Element_Divopen extends Zend_Form_Element_Xhtml { 

public $helper = 'formDivopen'; 
} 

MyApp/View/Helper/FormDivopen.php

require_once 'Zend/View/Helper/FormElement.php'; 
class MyApp_View_Helper_FormDivopen extends Zend_View_Helper_FormElement { 
public function formDivopen($name, $value = null, $attribs) { 
$info = $this->_getInfo($name, $value, $attribs); 
extract($info); 
$xhtml = '<div' 
    . ' name="'. $this->view->escape($name) . '"' 
    . ' id="'. $this->view->escape($id) . '"' 
    . ' value="'. $this->view->escape($value) . '"' 
    . $this->_htmlAttribs($attribs) 
    . '>'; 
return $xhtml 
} 
} 

И наконец: MyApp/View/Helper/FormDivclose.php

require_once 'Zend/View/Helper/FormElement.php'; 
class MyApp_View_Helper_FormDivclose extends Zend_View_Helper_FormElement { 
public function formDivclose($name, $value = null, $attribs) { 

$xhtml = '</div>'; 
return $xhtml 
} 
} 

Затем в форме:

$divOpen = $this->createElement('divopen', 'divname'); 
$this->addElement($divOpen); 

$mailRecepientName = new Zend_Form_Element_Text("mailRecepientName" . $id); 
$mailRecepientName->setRequired(true)->setLabel('اسم المستفيد')->setDecorators(array(
     'ViewHelper', 
     'Errors', 
     array(array('data' => 'HtmlTag'), array('tag' => 'span')), 
     array('Label', array('tag' => 'span')) 
    );); 

$mailRecepientNote = new Zend_Form_Element_Text("mailRecepientNote" . $id); 
$mailRecepientNote->setRequired(true)->setLabel('البيـــــــان')->setDecorators(array(
     'ViewHelper', 
     'Errors', 
     array(array('data' => 'HtmlTag'), array('tag' => 'span')), 
     array('Label', array('tag' => 'span')) 
    );); 
); 

$divClose = $this->createElement('divclose', 'closingdiv'); 
$this->addElement($divClose); 

Не уверен, что это лучший способ, но это может сделать трюк .. .

Смежные вопросы