Issues

ZF-6336: not able to reset Zend form

Description

I'm not sure if this has been reported or not but i'm not able to reset the field within Zend form using either javascript or Zend_Form_Element_Reset. Below is some simple script to generate the form. What you will notice is clicking on the reset button do not reset any of the fields within the form. What strange is that any fields that extends Zend_Dojo will get reset. If this is not a bug i hope someone could point out my mistake. Much appreciated.

    $form = new Zend_Form('test_form');
    $form->setName('test_form');
    $form->setAction('/zend-form/edit');
    $form->setAttrib('action','edit');
    $form->setMethod('post');

    $field2 = new Zend_Form_Element_Text('field2');
    $field2->setLabel('Field 2')
        ->setRequired(true)
        ->addValidator('alnum')
        ->addValidator('NotEmpty')
        ->addValidator('regex', false, array('/^[a-z]/'))
        ->addFilter('StringToLower');
    $form->addElement($field2);

    $field3 = new Zend_Form_Element_Textarea('field3');
    $field3->setLabel('Field 3')
        ->setRequired(true)
        ->addValidator('NotEmpty')
        ->addFilter('StripTags'); 
    $form->addElement($field3);

    $field4 = new Zend_Form_Element_Text('field4');
    $field4->setLabel('Field 4')
        ->setRequired(true)
        ->addValidator('stringLength', false, array(20))
        ->addValidator('EmailAddress')
        ->addFilter('StringTrim'); 
    $form->addElement($field4);

    $submit = new Zend_Form_Element_Submit('submit');
    $submit->setDecorators(
        array(
            array('ViewHelper'),
            array('Description'),
            array('HtmlTag', array('tag' => 'li', 'class' => 'submit-group')),
        )
    );
    $form->addElement($submit);

    $reset = new Zend_Form_Element_Reset('reset');
    $reset->setDecorators(
        array(
            array('ViewHelper'),
            array('Description'),
            array('HtmlTag', array('tag' => 'li', 'class' => 'submit-group')),
        )
    );
    $form->addElement($reset);


    $this->view->form = $form;

Comments

Ahhh i just narrow the problem. On the test form above i enabled Dojo as well included the dijit.form.Button module. This some how prevents the form from resetting. That said i now have a workaround.

thank you

Closing, per comment from poster.