zend_form
및 zend_decorator
과 관련된 문제가 있습니다.기본적으로 데코레이터를 덮어 쓰는 Zend_Form
모든 양식을 기본값으로 설정하여 목록 요소를 사용하는 데 데코레이터 클래스를 만들었지 만 작동하지 않는 것 같습니다!
기본적으로 my_decorator_design
은 zend_form
으로 확장되고 내 양식은 데코레이터를 확장합니다.
아이디어가 있으십니까?
class My_Decorator_Design extends Zend_Form {
public function loadDefaultDecorators() {
$this->addDecorator('FormElements')
->addDecorator('HtmlTag', array('tag' => 'ul')) //this adds a <ul> inside the <form>
->addDecorator('Form');
$this->setElementDecorators(array(
'ViewHelper',
'Label',
'Errors',
new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')) //wrap elements in <li>'s
));
$this->setDisplayGroupDecorators(array(
'FormElements',
'Fieldset',
new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')), //wrap groups in <li>'s too
new Zend_Form_Decorator_HtmlTag(array('tag' => 'ul'))
));
$this->setDisplayGroupDecorators(array(
'FormElements',
'Fieldset',
new Zend_Form_Decorator_HtmlTag(array('tag' => 'li')) //wrap groups in <li>'s too
));
}
}
class Forms_User_Update extends My_Decorator_Design {
public function __construct($options=array()) {
parent::__construct($options);//if we ever want to pass on things to zend_form
$this->setName('user_update');
$this->loadDefaultDecorators();
//user_name, first_name, email, password, date_of_birth
$user_name = new Zend_Form_Element_Text('user_name');
$first_name = new Zend_Form_Element_Text('first_name');
$email = new Zend_Form_Element_Text('email');
$password = new Zend_Form_Element_Password('password');
$password2 = new Zend_Form_Element_Password('password2');
$submit = new Zend_Form_Element_Submit('Submit');
$user_name->setRequired(true)
->setLabel('Username');
$first_name->setRequired(false)
->setLabel('First Name');
$email->setRequired(true)
->setLabel('Email:')
->addFilter('StringToLower')
->addValidator('NotEmpty', true)
->addValidator('EmailAddress');
$password->setLabel('Password:')
->setRequired(false)
->setIgnore(false)
->addValidator('stringLength', false, array(6));
$password2->setLabel('Confirm Password:')
->setRequired(false)
->setIgnore(true);
$submit->setLabel("Submit")
->setIgnore(true);
$this->addElements(array(
$user_name, $first_name, $email, $password, $password2, $submit
));
//$this->Submit->removeDecorator('Label');
//$this->addElementPrefixPath('My_Decorator', 'My/Decorator/', 'decorator');
$this->setMethod('post');
$this->setAction('/update-account');
}
}
귀하의 코드는 마지막에 잘라 것 같다 잘 작동 바랍니다. –
Nah 그곳에서 나온 일반적인 zend_form 코드입니다. 어쨌든 편집 할 것입니다. 감사합니다 – azz0r