Zend Form을 사용하여 Abide 검증을 사용하여 Foundation 5 양식을 렌더링하려고합니다. 나는 Zend의 ViewHelpers와 Decorator를 사용하여 재단에서 요구하는 div로 양식을 렌더링하는 방법을 완전히 이해하려고 애를 먹고 있습니다. 제대로 분류 된 div에 양식 요소를 래핑 할 수는 있지만, 여러 요소를 <div class="row">
에 넣을 수는 없습니다. 예.Zend Framework를 사용하여 폼 5 요소의 래퍼 div를 렌더링하는 방법
1) 각 양식 요소의 부모 DIV에 클래스 지정 : 여기
내가 달성 할 수없는 나는 것입니다. 모든 래퍼 div에 동일한 클래스 (아래 코드 참조)를 할당 할 수 있지만 개별 요소에는 할당 할 수 없습니다.$element->setAttrib('class','small-##')
을 추가하려고 시도했을 때 래퍼 div가 아닌
<input />
요소에 적용되었습니다. 예
firstName
lastName
과 다음 행의
company
는
class="small-12"
2 상태) class="small-6"
될 다음 행에 대한 형태를 다시 수행 후 <div class="row">
태그에 여러 형태의 소자를 배치하고 있어야 들어. 지금은 각 요소를 한 행에 넣을 수 있지만 여러 요소를 동일한 방법으로 넣는 방법을 모르겠습니다. <div class="row">
.
3) 기초 예제에서 <label>
태그는 <input>
태그를 감싸고 있지만 Zend는 입력 전에 레이블을 닫습니다. 이게 중요합니까? 여기
<form method="post" action="" enctype="multipart/form-data" data-abide>
<div class="row">
<div class="large-12 columns">
<div class="row">
<div class="small-2 columns">
<label for="display" class="inline">Display For: </label>
</div>
<div class="small-10 columns">
<input type="radio" name="display" value="0" id="displayEveryone" checked><label for="displayEveryone" class="inline">Everyone</label>
<input type="radio" name="display" value="999" id="displaySelf"><label for="displaySelf" class="inline">Only Me</label>
</div>
</div>
</div>
</div>
<div class="row">
<div class="small-6 columns">
<label>First Name
<input type="text" required class="contact" name="firstName" id="firstName" maxlength="25" autofocus="autofocus"/>
</label>
<small class="error">First name is required.</small>
</div>
<div class="small-6 columns">
<label>Last Name
<input type="text" required class="contact" name="lastName" id="lastName" maxlength="25"/>
</label>
<small class="error">Last name is required.</small>
</div>
</div>
<div class="row">
<div class="small-12 columns">
<label>Company or Affiliation
<input type="text" class="contact" name="company" id="company" maxlength="125"/>
</label>
</div>
</div>
<div class="row">
<div class="small-4 columns">
<label>Work Phone
<input type="text" class="contact" name="workPhone" id="workPhone" />
</label>
</div>
<div class="small-4 columns">
<label>Cell Phone
<input type="text" class="contact" name="cellPhone" id="cellPhone" />
</label>
</div>
<div class="small-4 columns">
<label>Home Phone
<input type="text" class="contact" name="homePhone" id="homePhone" />
</label>
</div>
</div>
</form>
을 그리고 여기에 내가 현재 가지고있는 젠드 양식 스크립트 및 변경해야합니다 :
class Application_Form_Contact extends Zend_Form
{
public function init()
{
$this->setMethod('post');
$this->setName('addContact');
$this->setAttrib('enctype', 'multipart/form-data') ;
$id = new Zend_Form_Element_Hidden('contactID');$id->addFilter('Int');
$display= new Zend_Form_Element_Radio('display');
$display->setLabel('Display For: ')
->setRequired(true)
->addMultiOptions(array(0 => "Everyone", 999 => "Only Me"));
$fName = new Zend_Form_Element_Text('firstName');
$fName->setLabel('First Name: ')
->setRequired(true)
->setAttrib('maxlength', 25)
->setAttrib('autofocus', 'autofocus')
->addFilter('StripTags')
->addFilter('StringTrim');
$lName = new Zend_Form_Element_Text('lastName');
$lName->setLabel('Last Name: ')
->setRequired(true)
->setAttrib('maxlength', 25)
->addFilter('StripTags')
->addFilter('StringTrim');
$company = new Zend_Form_Element_Text('company');
$company->setLabel('Company: ')
->setRequired(false)
->setAttrib('maxlength', 125)
->addFilter('StripTags')
->addFilter('StringTrim');
$workPhone = new Zend_Form_Element_Text('workPhone');
$workPhone->setLabel('Work Phone: ')
->setRequired(false)
->setAttrib('class', 'small-4')
->addFilter('StripTags')
->addFilter('StringTrim');
$cellPhone = new Zend_Form_Element_Text('cellPhone');
$cellPhone->setLabel('Cell Phone: ')
->setRequired(false)
->setAttrib('class', 'small-4')
->addFilter('StripTags')
->addFilter('StringTrim');
$homePhone = new Zend_Form_Element_Text('homePhone');
$homePhone->setLabel('Home Phone: ')
->setRequired(false)
->setAttrib('class', 'small-4')
->addFilter('StripTags')
->addFilter('StringTrim');
$otherPhone = new Zend_Form_Element_Text('otherPhone');
$otherPhone->setLabel('Other Phone: ')
->setRequired(false)
->addFilter('StripTags')
->addFilter('StringTrim');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $display, $fName, $lName, $company, $workPhone, $cellPhone, $homePhone, $otherPhone, $submit));
$this->setElementDecorators(array(
'ViewHelper',
array('Description'),
array('Errors'),
array(array('data' => 'HtmlTag'), array('tag' => 'div', 'class'=>'small-6 columns')),
array('Label'),
array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class'=> 'row'))
));
$submit->setDecorators(array(
'ViewHelper',
array(array('data' => 'HtmlTag')),
array(array('row' => 'HtmlTag'))
));
$this->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'div', 'class'=>'small-12 columns')),
array('Form', array('data-abide'=>'data-abide'))
));
$view = $this->getView();
$formErrors = $view->getHelper('formErrors');
$formErrors->setElementStart('<small class="error">')
->setElementSeparator('')
->setElementEnd('</small>');
}
}
당신의 도움에 감사드립니다.