Pretty simple Jgadbois,

Here could be a little example of what u would want. (in cakephp 1.2)

//this doesn't have to be so complicated but im just showing u the
options of the create
//function. create('Recipe'); would automagically bring you to the add
action.
echo $form->create('Recipe', array('method' => 'post', 'url' => array
('action' => 'add')));
  echo $form->input('Recipe.name');
  echo $form->input('Ingredients.name');
  echo $form->input('Ingredients.quantity');
echo $form->end();

That is the code within the view, in the controller you can do all the
logic you want with this stuff by looking at $this->data.
$this->data would look something like this:
array (
       [Recipe] => array (
                                  [name] => hot fudge cake
                                 )
       [Ingredients] => array (
                                       [name] => flower
                                       [quantity] => 2
                                       )
)

and to save this information all you need to do is use the saveAll
function
$this->Recipe->saveAll($this->data);

the saveAll method looks for associations and saves the information
properly.

I hope this helped you, i'm not sure how new you are so i tried to put
it as simple as possible and explain things.

Happy Baking.

On May 29, 10:44 am, jgadbois <[email protected]> wrote:
> What is the preferred way for handling a form with elements for
> mutitple models?  In my case, I'd like to have a form where you can
> add a Recipe with all of it's Ingredients (a recipe hasMany
> ingredients).  How would I handle this?  I'm new to CakePHP so I'm a
> little confused.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to