2

I create a form in a Zend Framework using jquery:

    class Contact_Form_Contact extends ZendX_JQuery_Form {

  public function init() {
        /* Form Elements & Other Definitions Here ... */
        //create new element
        $name = $this->createElement('text', 'name');
        //element options
        $name->setLabel("Enter your name:");
        $name->setRequired(TRUE);
        $name->setAttrib('size', 40);
        //add element to the form

        $this->addElement($name);
        .....

If request fails setRequired enables class=errors,

How to override it to "ui-state-error my-clean"?

Arman.

Arman
  • 4,566
  • 10
  • 45
  • 66

2 Answers2

3

Instead of overwriting decorators, you can set decorator options that way:

$element->getDecorator('Errors')->setOption('class', 'ui-state-error my-clean')
Radek Benkel
  • 8,278
  • 3
  • 32
  • 41
2

After seriously reading the blogs of Zend I found that it is very easy to do that with decorator:

  $this->setElementDecorators(array(
        'ViewHelper',
        'Label',
        array('Errors', array('class'=>'ui-state-error'))
    ));
Arman
  • 4,566
  • 10
  • 45
  • 66