On Mar 2, 12:33 pm, TGurske <[email protected]> wrote:
> That seems to work but how do I get it to make a new id in the
> location table? In 'Location.0.name' I think it's trying to insert it
> into id '0'.
If the Location table has an autoincrementing ID field and you do have
the user enter the ID on the form, then Cake should automatically
create the appropriate Location record(s) (with the ID field
populated) and associate them correctly when you do a 'saveAll'. That
middle number is just an array index to signify a new, seperate record
for an associated model. So if you wanted to add and associate three
Locations in one go, then you might have something like:
$form->input('Location.0.name');
$form->input('Location.0.address');
$form->input('Location.1.name');
$form->input('Location.1.address');
$form->input('Location.2.name');
$form->input('Location.2.address');
After form submission, this portion of the form will be translated to
(using example data):
[Location] => array (
[0] => array (
[name] => foo
[address] => 612 wharf ave.
[1] => array (
[name] => bar
[address] => 1234 easy st.
[2] => array (
[name] => baz
[address] => 1337 cake dr.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---