How to submit a Zend Dojo subForm

680 Views Asked by At

I have spent hours on the net to find a solution, but nothing works.

I have a form divided into 2 subForms (I couldn't get the accordion pane to work)

like this :

$sfBase = new Zend_Dojo_Form_SubForm('base_info');
$sfBase->setName('base_info')
            ->setAction('/product/add?f=1');

$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int')
      ->setAttrib('style', 'display:none');

$nom = new Zend_Dojo_Form_Element_TextBox('name');
$nom->setLabel('Nom du produit')
     ->setTrim(true)
     ->setValue("Entrez le nom")
     ->setPropercase(true);

$sdesc = new Zend_Dojo_Form_Element_TextBox('sdesc');
$sdesc->setLabel('Courte description du produit')
      ->setTrim(true)
      ->setValue("Description")
      ->setPropercase(true);

$sfBase->addElements(array($id, $nom, $sdesc);

$submitSubBase = new Zend_Dojo_Form_Element_SubmitButton('sub1');
$submitSubBase->setLabel('ok');
$sfBase->addElement($submitSubBase);

and another subform which contains few other elements :

$sfComp = new Zend_Dojo_Form_SubForm('comp_info');
$sfComp->setName('comp_info')
       ->setAction('/product/add?f=2');
...
$submitSubComp = new Zend_Dojo_Form_Element_SubmitButton('sub2');
$submitSubComp->setLabel('envoyer');
$sfComp->addElement($submitSubComp);

$this->addSubForms(array('base_info' => $sfBase,
            'comp_info' => $sfComp
            ));

In my controller I display the entire instanciated form :

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

but whenever I click on a submit button nothing happens. I tried placing a single submit button added to the form (not to a subForm)

with setAction :

$baseForm->setAction($this->view->url(
            array('controller' => 'Product', 'action' => 'add', 'id' => '1'), 'default', 
            true));

but it is the same, finally I divided the form into two distinct Zend_Form instead of subforms, but that is not very clean...

So having tried multi page forms, subForms and dojo containers unsuccessfully I don't know what to do, and any help would be welcome !

thank you

1

There are 1 best solutions below

0
On

I don't know if this will help at all but here is my answer.

If the MAIN form is not Dojo enabled, have you called Zend_Dojo::enableForm() in the init method? Is the MAIN form extending frorm Zend_Dojo_Form? If it's extending from Zend_Dojo_Form then you don't have to call Zend_Dojo::enableForm().

The Dojo forms submit through the use of javascript. You should have some javascript on the client side that can handle the responses from the server that will come back. If you don't have javascript on the client side to handle these returns, then you won't 'see' the results of the submit.

Try this, write some javascript using the dojo toolkit that will create an alert box when it receives something from the server. This way, if you click on the submit button and an alert box comes up you'll know that the form was submitted.