Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 606749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:17:14+00:00 2026-05-13T17:17:14+00:00

I am having issues with zend_form and zend_decorator . I have created a decorator

  • 0

I am having issues with zend_form and zend_decorator.

I have created a decorator class to default all forms to use list elements, however it doesn’t seem to be working!

Essentially my_decorator_design extends zend_form and then my forms extend the decorator.

Ideas?

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');    
  }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T17:17:14+00:00Added an answer on May 13, 2026 at 5:17 pm

    You call loadDefaultDecorators in the constructor, and call setElementDecorators from there.

    But addElement uses the element decorators only when you construct elements from strings, not when you pass a ready made element, while setElementDecorators only sets the decorators for the already existing controls (which are none in the constructor).

    As you create the elements first and then pass them as Elements the element decorators are never set.

    Remove the call to loadDefaultDecorators in the constructor.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im having issues getting this to work, maybe its not even possible? I have
By far, the most common class of errors I have are issues with the
im having issues with the following interface and a class: public interface IRelated {
I'm having an issue with assertRedirectTo() in a test I have created, below is
Having issues with screen progress. I have a screen displaying information from a database.
Having issues with my apps on Google Play. I have a free app which
Having issues getting django custom commands to work. From django documetation , have placed
Having issues using the PHP memcached class. I am running a LAMP environment on
Having issues with Twitter Bootstrap responsive navigation. The best way to explain this is
Having issues referencing $(this) from within a the nested ajax 'success' function... I know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.