Just started with Cake for one simle app - online daily menu editor. Briefly. One menu has many menu items. One menu item = one dish. one dish = one dish type. There are 9 dish types (it's an indian restaurant, so it's rice, naan, curry, veg. curry etc). Here is the db structure
CREATE TABLE `dish_types` ( `id` int(11) NOT NULL auto_increment, `name` varchar(100) collate utf8_czech_ci NOT NULL, PRIMARY KEY (`id`) ) CREATE TABLE `dishes` ( `id` int(11) NOT NULL auto_increment, `name_en` text collate utf8_czech_ci NOT NULL, `name_cs` text collate utf8_czech_ci NOT NULL, `dish_type_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `NewIndex1` (`dish_type_id`), CONSTRAINT `FK_dishes` FOREIGN KEY (`dish_type_id`) REFERENCES `dish_types` (`id`) ON DELETE CASCADE ) CREATE TABLE `menu_items` ( `id` int(11) NOT NULL auto_increment, `menu_id` int(11) NOT NULL, `dish_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `NewIndex1` (`menu_id`), KEY `NewIndex2` (`dish_id`), CONSTRAINT `FK_menu_items` FOREIGN KEY (`dish_id`) REFERENCES `dishes` (`id`) ON DELETE CASCADE, CONSTRAINT `FK_menu_items1` FOREIGN KEY (`menu_id`) REFERENCES `menus` (`id`) ON DELETE CASCADE ) CREATE TABLE `menus` ( `id` int(11) NOT NULL auto_increment, `created` timestamp NOT NULL default CURRENT_TIMESTAMP, `forday` date NOT NULL, PRIMARY KEY (`id`) ) Here is how I define model associations class Menu extends AppModel { var $hasMany = array( 'MenuItem' => array( 'className' => 'MenuItem', 'order' => 'Dish.dish_type_id asc' ) ); } class Dish extends AppModel { var $belongsTo = 'DishType'; } class MenuItem extends AppModel { var $hasOne = 'Dish'; } Now my trouble begin. I have a controller MenusController and an action create. In the view create.ctp I want to see one date field (that works) and 9 select fields to choose the 9 dishes for the day. Now the question. How do I automagically create the 9 select fields. I understand the mechanism for 1 attribute, ie. if I do in controller $this->set ('dishes', $this->Dish->find('list')); and in the view echo $form->input('Dish'); the select is there and filled as expected. But how to show 9 of them, each having only a subset of dishes. first only rice, second naan etc)? What I do now, is that in the view I manually render, using $form- >select all 9 selects. But I feel that this is not exactly how is cake supposed to be used. Thanks, Michal --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---