-- Guillaume Oriol <[email protected]> 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.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to