Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Form, overwriting decorators by default, not working
    primarykey
    data
    text
    <p>I am having issues with <code>zend_form</code> and <code>zend_decorator</code>.</p> <p>I have created a decorator class to default all forms to use list elements, however it doesn't seem to be working!</p> <p>Essentially <code>my_decorator_design</code> extends <code>zend_form</code> and then my forms extend the decorator. </p> <p>Ideas?</p> <pre><code>class My_Decorator_Design extends Zend_Form { public function loadDefaultDecorators() { $this-&gt;addDecorator('FormElements') -&gt;addDecorator('HtmlTag', array('tag' =&gt; 'ul')) //this adds a &lt;ul&gt; inside the &lt;form&gt; -&gt;addDecorator('Form'); $this-&gt;setElementDecorators(array( 'ViewHelper', 'Label', 'Errors', new Zend_Form_Decorator_HtmlTag(array('tag' =&gt; 'li')) //wrap elements in &lt;li&gt;'s )); $this-&gt;setDisplayGroupDecorators(array( 'FormElements', 'Fieldset', new Zend_Form_Decorator_HtmlTag(array('tag' =&gt; 'li')), //wrap groups in &lt;li&gt;'s too new Zend_Form_Decorator_HtmlTag(array('tag' =&gt; 'ul')) )); $this-&gt;setDisplayGroupDecorators(array( 'FormElements', 'Fieldset', new Zend_Form_Decorator_HtmlTag(array('tag' =&gt; 'li')) //wrap groups in &lt;li&gt;'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-&gt;setName('user_update'); $this-&gt;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-&gt;setRequired(true) -&gt;setLabel('Username'); $first_name-&gt;setRequired(false) -&gt;setLabel('First Name'); $email-&gt;setRequired(true) -&gt;setLabel('Email:') -&gt;addFilter('StringToLower') -&gt;addValidator('NotEmpty', true) -&gt;addValidator('EmailAddress'); $password-&gt;setLabel('Password:') -&gt;setRequired(false) -&gt;setIgnore(false) -&gt;addValidator('stringLength', false, array(6)); $password2-&gt;setLabel('Confirm Password:') -&gt;setRequired(false) -&gt;setIgnore(true); $submit-&gt;setLabel("Submit") -&gt;setIgnore(true); $this-&gt;addElements(array( $user_name, $first_name, $email, $password, $password2, $submit )); //$this-&gt;Submit-&gt;removeDecorator('Label'); //$this-&gt;addElementPrefixPath('My_Decorator', 'My/Decorator/', 'decorator'); $this-&gt;setMethod('post'); $this-&gt;setAction('/update-account'); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload