Note that there are some explanatory texts on larger screens.

plurals
  1. POZend_Form using subforms getValues() problem
    primarykey
    data
    text
    <p>I am building a form in Zend Framework 1.9 using subforms as well as Zend_JQuery being enabled on those forms. The form itself is fine and all the error checking etc is working as normal. But the issue I am having is that when I'm trying to retrieve the values in my controller, I'm receiving just the form entry for the last subform e.g.</p> <p>My master form class (abbreviated for speed):</p> <pre><code>Master_Form extends Zend_Form { public function init() { ZendX_JQuery::enableForm($this); $this-&gt;setAction('actioninhere') ... -&gt;setAttrib('id', 'mainForm') $sub_one = new Form_One(); $sub_one-&gt;setDecorators(... in here I add the jQuery as per the docs); $this-&gt;addSubForm($sub_one, 'form-one'); $sub_two = new Form_Two(); $sub_two-&gt;setDecorators(... in here I add the jQuery as per the docs); $this-&gt;addSubForm($sub_two, 'form-two'); } } </code></pre> <p>So that all works as it should in the display and when I submit without filling in the required values, the correct errors are returned. However, in my controller I have this:</p> <pre><code>class My_Controller extends Zend_Controller_Action { public function createAction() { $request = $this-&gt;getRequest(); $form = new Master_Form(); if ($request-&gt;isPost()) { if ($form-&gt;isValid($request-&gt;getPost()) { // This is where I am having the problems print_r($form-&gt;getValues()); } } } } </code></pre> <p>When I submit this and it gets past isValid(), the $form->getValues() is only returning the elements from the second subform, not the entire form.</p>
    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