Web Images Videos Maps News Groups Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Format for data in a HABTM save
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
carl67lp  
View profile  
 More options Nov 9, 12:53 pm
From: carl67lp <ccander...@gmail.com>
Date: Sun, 8 Nov 2009 17:53:53 -0800 (PST)
Local: Mon, Nov 9 2009 12:53 pm
Subject: Format for data in a HABTM save
Apologies if this has been answered elsewhere; a reasonably thorough
search of this group and of the CakePHP docs yielded no useful
results.

I've got an app that categorizes board games; it pulls data via XML
feed from an external site.  My models are such that Game is the
"master" model, and it goes thusly:

Game HABTM Artist
Game HABTM Category
Game HABTM Designer

...and so on.

For a particular game, there can exist multiple artists, multiple
categories, and so on.  For example, the game "Die Macher" has only
one designer, but three publishers and several categories.

I'm able to put the artist/category/designer data into the appropriate
tables as needed.  What I can't seem to figure out is how to properly
construct my $this->data array so that I can save the artists_games
HABTM linkages.

Am I close with something like this?

$this->data['Game'] = array
(
'Artist' => array('Artist.id' => $artist_id, 'Game.id' => $game_id),
'Category' => array('Category.id' => $category_id, 'Game.id' =>
$game_id),
...
);

The documentation has everything coming in from a form; my app has
everything coming in from XML--thus, I need to manually create $this-

>data.

Incidentally: my baked view for /game/add/ have what look like multi-
select boxes for Artist/Category/etc., but no data inside.  Did I miss
something somewhere?

Many thanks for any assistance you can provide.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
carl67lp  
View profile  
 More options Nov 10, 11:31 am
From: carl67lp <ccander...@gmail.com>
Date: Mon, 9 Nov 2009 16:31:33 -0800 (PST)
Local: Tues, Nov 10 2009 11:31 am
Subject: Re: Format for data in a HABTM save
For those struggling with the same problem, I've found a solution.
The array should be formatted as in the last comment on this page:

http://teknoid.wordpress.com/2009/03/30/revisiting-saveall-and-habtm/

Also note that you need saveAll(), not just save() ... it would seem.

--Carl

On Nov 8, 8:53 pm, carl67lp <ccander...@gmail.com> wrote:


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google