Thomas VEQUAUD schreef: > > Damn, I met this issue 2 months ago and I was persuaded it was a regular > behavior of subforms... > > > On Thu, Apr 23, 2009 at 4:32 PM, Matthew Weier O'Phinney > <matt...@zend.com > <mailto:matt...@zend.com>> wrote: > > -- Guillaume Oriol <gor...@technema.fr > <mailto:gor...@technema.fr>> wrote > (on Thursday, 23 April 2009, 07:14 AM -0700): > > I designed a generic CRUD controller doing the following > operations for the > > CREATE action: > > > > if ($this->_request->isPost()) { > > $formData = $this->_request->getPost(); > > if ($form->isValid($formData)) { > > $row = $this->_model->createRow(); > > $row->setFromArray($form->getValues()); > > $row->save(); > > $this->goBack(); // Exit here > > } > > // Repopulate the form if it is not valid > > $form->populate($formData); > > } > > ... > > > > When my form has no subform, everything is okay, but when my form > has subforms, > > no data is saved. > > What am I supposed to do when using subforms? Iterating thru > subforms to get > > the data? > > > > ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ > > Without subforms $form->getValues() returns an array like: > > > > array ( > > 'name' => 'aaa', > > 'description' => 'bbb', > > 'submit' => 'submit', > > ) > > > > With subforms, $form->getValues() returns something like: > > > > array ( > > 'submit' => 'submit', > > '' => array ( > > 'name' => 'aaa', > > 'description' => 'bbb', > > ) > > ) > > This behavior was recently reported on the issue tracker and fixed in > trunk, iirc. >
Thomas: The form values are still given as multidimensional arrays. Correct me if I'm wrong. But I think Matthew is referring to the missing subForm name as the key in the array, right Matthew? I fixed this in a project of mine by making the subForm an explicit instance of Zend_Form_SubForm. (As was suggested in the issue as a temporal fix)