1
처럼 테이블에 내 양식을 래핑하는 트링, 그래서 HTML 출력이 같습니다젠드 프레임 워크 양식 테이블 장식
class Forms_PageEdit extends Zend_Form
{
public $elementDecorators = array(
'ViewHelper',
'Errors',
array(
array('data' => 'HtmlTag'),
array('tag' => 'td', 'class' => 'td3')
),
array('Label',
array('tag' => 'td', 'class'=>'td2')
),
array(
array('row' => 'HtmlTag'),
array('tag' => 'tr')
),
);
public function init()
{
$this->setMethod('post');
$this->setDisableLoadDefaultDecorators(true);
$this->removeDecorator('DtDdWrapper');
$this->setDecorators(array(
'FormElements',
array('HtmlTag',array('tag'=>'table', 'width'=>'100%', 'cellspacing' => '0', 'cellpadding'=>'0')),
'Form'
));
// Add an page name
$this->addElement('text', 'name', array(
'label' => STC_Model::getInstance('AdminPhrases')->getPhraseByName('pages_edit_name',3),
'decorators' => $this->elementDecorators,
'required' => true,
'filters' => array('StringTrim'),
));
// add Page SEO Name Element
$this->addElement('text', 'seo_name', array(
'label' => STC_Model::getInstance('AdminPhrases')->getPhraseByName('pages_edit_seo',3),
'decorators' => $this->elementDecorators,
'required' => true,
));
// add Page Title Element
$this->addElement('text', 'title', array(
'label' => STC_Model::getInstance('AdminPhrases')->getPhraseByName('pages_edit_title',3),
'decorators' => $this->elementDecorators,
));
// add Page Title Element
$this->addElement('text', 'order', array(
'label' => STC_Model::getInstance('AdminPhrases')->getPhraseByName('pages_edit_seo',3),
'decorators' => $this->elementDecorators,
'required' => true,
'validators' => array(
array('Digits'),
array('GreaterThan', -1),
),
));
// Add the submit button
$this->addElement('submit', STC_Model::getInstance('AdminPhrases')->getPhraseByName('save'), array(
'decorators' => array(
'ViewHelper',
'Errors',
array(
array('data' => 'HtmlTag'),
array('tag' => 'td', 'class' => 'td1', 'colspan' => '2', 'align' => 'center')
),
array(
array('row' => 'HtmlTag'),
array('tag' => 'tr')
),
),
'ignore' => true,
));
$element = $this->getElement(STC_Model::getInstance('AdminPhrases')->getPhraseByName('save'));
$element->removeDecorator('label');
$element->removeDecorator('DtDdWrapper');
// And finally add some CSRF protection
$this->addElement('hash', 'csrf', array(
'ignore' => true,
));
$element = $this->getElement('csrf');
$element->removeDecorator('label');
$element->removeDecorator('DtDdWrapper');
}
}
:
<form enctype="application/x-www-form-urlencoded" method="post" action="">
<table width="100%" cellspacing="0" cellpadding="0">
<tr>
<td id="name-label" class="td2 required">Page Name</td>
<td class="td3">
<input type="text" name="name" id="name" value="">
</td>
</tr>
<tr>
<td id="seo_name-label" class="td2 required">Page SEO Name</td>
<td class="td3">
<input type="text" name="seo_name" id="seo_name" value="">
</td>
</tr>
<tr>
<td id="title-label" class="td2 optional">Page Title</td>
<td class="td3">
<input type="text" name="title" id="title" value="">
</td>
</tr>
<tr>
<td id="order-label" class="td2 required">Page SEO Name</label></td>
<td class="td3">
<input type="text" name="order" id="order" value="">
</td>
</tr>
<tr>
<td class="td1" colspan="2" align="center">
<input type="submit" name="Save" id="Save" value="Save">
</td>
</tr>
<input type="hidden" name="csrf" value="0fd12c3fd912bb8f2e59ccae28c886f5" id="csrf">
</table>
</form>
그래서 내가 몇 가지 검색의 기반이를 썼다
하지만 정말 일은이 각 레이블입니다 :
이 이가 어떻게 라벨 있도록 조정할 수 있습니다
<td id="name-label"><label for="name" class="td2 required">Page Name</label></td>
내가 원하는 방식은?
네, 잘 작동합니다. – Pyromanci
방금 뭔가 알았지 만. echo $ this-> {$ this-> element-> helper} ($ this-> element-> getName(), $ this-> element-> getValue(), $ this-> element-> getAttribs())를 사용한다. 샘플에서 그들은 라디오 그룹 페이지를 표시하지 않습니다. – Pyromanci