Use two save commands:

$this->A->save($this->data['A']);
$this->A->B->save($this->data['B']);

I think there's a new(er) function called saveAll(), which should do
what you want automatically.  I'm not sure about the level of
implementation for that yet, though, it may only be in the latest beta
release.

Casey

On Mar 6, 11:19 am, "Juan Luis Baptiste" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I have two models that have associations between them. Let call them A
> and B. B has a belongsTo association with A and A has a hasMany
> association with B. For model A I have an action called "register" and
> the form in it's view has fields for both models so I can use the same
> for to save the info for both. Someone on IRC told me that cake was
> able to save both models when the method $this->A->save($this->data)
> was called but that isn't working for me, it only saves data for model
> A. I tried doing it the other way, adding the register action to B
> controller and doing $this->B->save($this->data) there but it doesn't
> work either. I also tried calling the add method in B controller from
> A controller but it seems that cake tries to excecute "add" as an SQL
> string and get an SQL error instead of calling the method.
>
> So is there a way to save both models from same controller ?
>
> Thanks,
> --
> Juan Luis Baptiste
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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