rhythmicdevil,

Cake will use Names instead of ID's on immediate "children" of Models
provided that you are using the fieldname 'Name'.  For example, if
you're relating Posts to Users and you have the 'user_id' field in
your Posts table and you also have the 'name' field in your Users
table, CakePHP will populate the values of the 'Users.Name' in your
Posts view.  Make sense?

If you're "child" Model is actually a "sub-child".  For example, in
the small CMS I am writing, I have the following relationship:

Posts
     -> hasMany Meta (Meta table consists of id, meta_tags, and
value).
          ->hasOne MetaValue

So my Posts are setup to recognize many Meta values...with each value
(title value, description value, author value, etc.) with each key
having a unique key (title, description, author).  I wanted the
ability to add, on the fly, additional keys (pageviews, for example).
So, my Metas table has a field of 'meta_value_id' which relates to the
'meta_values' table.  Make sense?

Posts won't display via the Bake method the values of the keys stored
in Meta...so I had to add a simple query in the 'view' of my
Controller:

                $this->set( 'meta_tags' , $this->Content->Meta->read( null ,
$id ) );

This gives me the correspondeing information from my secondary table
(related).  A little PHP and I can have my Posts index view display
the following (example):

Title                            Meta
Tag                                  Value
My first post!
description                               My very first post!

If I don't add the little PHP you see above, you get the 'id' field:

Title                            Meta
Tag                                  Value
My first post!
1                                         My very first post!

See the difference?

I've thought that the finderQuery or counterQuery in the Posts model
could make this easier.  Perhaps it does.  But I've yet to find good
information to suggest so and when I've played with it I've gotten
nothign but erros using the Christmas release.

I hope I haven't confused you too much!


On Jan 8, 4:59 pm, "rhythmicde...@gmail.com" <rhythmicde...@gmail.com>
wrote:
> So first, this Bake is pretty impressive in all that it auto builds. I
> must say the team did a ton of work to make this happen.
>
> Ok so I just did my first run and I have a bunch of views, models and
> controllers. They all seem to work. The question I have is this:
>
> I have several inter-related models where one supplies a list for a
> select list in another. For instance:
>
> IngredientType should supply a list of ingredient_types to Ingredient
> so that in the view you would get a select list of those ingredient
> types.
>
> What I am getting is the IDs and not the name fields.
>
> Is this correct or did I make a mistake in a definition somewhere.
>
> I guess my question is. should I expect those fields to have names?
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to