Wednesday, July 29, 2009

Saving both habtm and hasmany data

After quite a bit of back and forth, I decided to forge ahead with
CakePHP for the first time. I am running into troubles right now
trying to get certain data to save properly.

The form I am using is attempting to save data to several different
models:

phones
emails
profiles
businesses

The relationship of these models is as follows:

profiles hasMany phones and emails
businesses HABTM profiles

Now my form allows people to fill out information about themselves
(and thus add a profile) and submit it on behalf of their business. I
need cake to enter in profile, save the phone and email, then enter in
the business, and make the habtm relationship.

I was hoping cake could do all of this 'automagically', but it doesn't
seem to be working.What I currently have is:

$this->Business->Profile->saveAll($this->data);
$this->Business->saveAll($this->data);

Can cake do this automatically, or will I have to step cake through
the saves?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: