So I have a cookbook application with recipes and categories:
Recipes
id:title:recipe:created_on:category_id
Categories
id:name
I am trying to use bake to setup the associations between the categories and
recipes:
CATEGORY MODEL
class Category extends AppModel {
var $name = 'Category';
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $hasMany = array(
'Recipe' =>
array('className' => 'Recipe',
'foreignKey' =>
'category_id',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'dependent' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
}
RECIPE MODEL
class Recipe extends AppModel {
var $name = 'Recipe';
//The Associations below have been created with all possible keys,
those that are not needed can be removed
var $hasOne = array(
'Category' =>
array('className' => 'Category',
'foreignKey' => 'id',
'conditions' => '',
'fields' => '',
'order' => '',
'dependent' => ''
),
);
}
Do I have the concept or am I missing something?
I also had bake setup the controllers and views for me. When I view a recipe
say with category_id = 2, category 1 shows up under views. Also should the
add/edit view generated by scaffold have the categories as a select box with
the categories in it? Right now I have a text box which makes me think that
I don't have the associates set up correctly.
Thanks Mark
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---