Solved. I moved the Profession key back up to the same level as Business. The 
save($business) function now collects the Business key, and then parses the 
$business array for keys that match any habtm associated models (i.e. 
Profession) and performs a save on them too.

I know this is not exactly a revelation for those of you who knew this, but I 
hadn't picked that up and hope it helps others.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 24 Mar 2011, at 15:44, Jeremy Burns | Class Outfit wrote:

> Thanks for the reply.
> 
> Yes, I am using the Form helper and have tried saveAll, which has no effect.
> 
> The only out-of-the-norm thing is that the Form model is not Business - it is 
> a level above, so my input is as follows:
> 
> echo $this->Form->input('Business.Profession');
> 
> However, the data array coming out is in the right shape so I have 
> (foolishly?) disregarded this as a problem.
> 
> Jeremy Burns
> Class Outfit
> 
> [email protected]
> http://www.classoutfit.com
> 
> On 24 Mar 2011, at 15:30, Kole Reece wrote:
> 
>> try the SaveAll method.Are you using the form helper to get your data ?
>> 
>> Kole 
>> 
>> On Thu, Mar 24, 2011 at 10:19 AM, Jeremy Burns <[email protected]> 
>> wrote:
>> I have a form that contains a habtm input. The array sent into the
>> Business model on an insert looks a little like this:
>>  [Business] => Array
>>        (
>>            [address_1] => xxx
>>            [...other fields...]
>>            [Profession] => Array
>>                (
>>                    [0] => 32
>>                    [1] => 19
>>                    [2] => 30
>>                )
>>        )
>> 
>> Note there is no field for Business.id as it is a new record.
>> 
>> This command in the Business model:
>> 
>> $this->save($business)
>> 
>> ...creates the new Business record, but not the Profession habtm
>> records.
>> 
>> $this->save($business['Business']) does the same thing.
>> 
>> I thought that when I save the containing model the habtm records
>> would also be inserted? What am I doing wrong?
>> 
>> --
>> Our newest site for the community: CakePHP Video Tutorials 
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
>> others with their CakePHP related questions.
>> 
>> 
>> To unsubscribe from this group, send email to
>> [email protected] For more options, visit this group at 
>> http://groups.google.com/group/cake-php
>> 
>> 
>> -- 
>> Our newest site for the community: CakePHP Video Tutorials 
>> http://tv.cakephp.org 
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
>> others with their CakePHP related questions.
>>  
>>  
>> To unsubscribe from this group, send email to
>> [email protected] For more options, visit this group at 
>> http://groups.google.com/group/cake-php
> 
> 
> -- 
> Our newest site for the community: CakePHP Video Tutorials 
> http://tv.cakephp.org 
> Check out the new CakePHP Questions site http://ask.cakephp.org and help 
> others with their CakePHP related questions.
>  
>  
> To unsubscribe from this group, send email to
> [email protected] For more options, visit this group at 
> http://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to