I would like to apologize for being a nuisance. It is ok. Your English is understandable, it is only probably I couldn't get the point, not really used to using cakePhp, somehow have a sense of being restricted, which may be the fact that I am not used to it.
Hardcoring can get things pretty straight forward, but it takes time. Hence, it is kind of a trade off in between. > If you have all associations set correctly, you can put in the > ProductsController: Is there anything that I will need to set in besides this: $this->set('categories', $this->Product->Category->generateList(null, null, null, "{n}.Category.id", "{n}.Category.catname")); Is it the $hasMany (for Product) and $BelongsTo (Category) under their model? If it is these, then I have tried but there is an issue whenever I do any action to them (add, edit, etc), they will prompt for the table products_categories error. Do I have to set a table for it, or otherwise? Below is the output result: <output result> Query: DELETE FROM `categories_products` WHERE cat_id = '7' Warning: SQL Error: 1146: Table 'testdb.categories_products' doesn't exist in /home/testdb/cake/libs/model/datasources/dbo_source.php on line 440 Query: INSERT INTO `categories_products` (cat_id,category_id) VALUES (7,6) Warning: SQL Error: 1146: Table 'testdb.categories_products' doesn't exist in /home/testdb/cake/libs/model/datasources/dbo_source.php on line 440 Warning: Cannot modify header information - headers already sent by (output started at /home/testdb/cake/basics.php:697) in /home/testdb/ cake/libs/controller/controller.php on line 447 </output result> Thanks for your assistance. On Dec 1, 8:04 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote: > Hi,> I don't quite get you. > > that's probably because my English sucks! (I'm a Spanish speaker) > > > Do you mean something like this if I have a > > products table with fieldname: id, productname, cat_id, and I would > > need a select element under the product, where I will be able to > > select the categories? > > > $this->set('categories', $this->Category->generateList(null, null, > > null, "{n}.categories.id", "{n}.categories.catname")); > > > Do I put this under the Category Controller or Products Controller? > > If you have all associations set correctly, you can put in the > ProductsController: > > $this->set('categories', > $this->Product->Category->generateList(null, null, null, > "{n}.Category.id", "{n}.Category.catname")); > > > Thanks. > > You're welcome. > > > On Dec 1, 5:41 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote: > > > I you want to use fields from associated tables, use the key/valuePath > > > options in Model::generateList(), and set recursive to the apropiate > > > value. > > > > 2007/11/30, Dardo Sordi Bogado <[EMAIL PROTECTED]>: > > > > > This is for fields from the same table. I don't understand what you > > > > mean with "the aro aco method". > > > > > 2007/11/30, Joyce <[EMAIL PROTECTED]>: > > > > > > Can this solution for fieldname within same table be used with those > > > > > that are of different tables? Or do I have to use the aro aco method > > > > > for that? > > > > > > Thanks. > > > > > > On Dec 1, 4:23 am, "Dardo Sordi Bogado" <[EMAIL PROTECTED]> wrote: > > > > > > There are thre ways: > > > > > > > 1. If you are using Model::generateList(), ex: > > > > > > > // generateList ($conditions, $order, $limit, > > > > > > $keyPath=, $valuePath) > > > > > > $categories = $this->Category->generateList(null, null, null, null, > > > > > > '{n}.Category.catname'); > > > > > > > 2. Also you can just set Model::$displayField : > > > > > > > class Category extends AppModel { > > > > > > var $name = 'Category'; > > > > > > var $displayField = 'catname'; > > > > > > > } > > > > > > > Then, it becomes: > > > > > > > $categories = $this->Category->generateList(); > > > > > > > 3. You can rename colmn catname to name (default displayField). > > > > > > > I think number 2 is best. > > > > > > > Dardo Sordi. > > > > > > > 2007/11/30, Joyce <[EMAIL PROTECTED]>: > > > > > > > > Hi all, > > > > > > > > I am a newbie in cakePHP, and I have created a table as per below. > > > > > > > > I have 3 fields for my categories table, and would like tocreatea > > > > > > > Select form element to insert new categories and link within the > > > > > > > table > > > > > > > itself(where the parent_id comes from the id). > > > > > > > > Such that it will echo the select option in this manner: > > > > > > > <select><option value="id">catname</option></select>, where the > > > > > > > values > > > > > > > of "id" and "catname" are populated from the table below. > > > > > > > > categories table: > > > > > > > id > > > > > > > catname > > > > > > > parent_id > > > > > > > > I have tried some of the ways that will google help, but none > > > > > > > seems > > > > > > > successful, in which I could only end up with the id instead of > > > > > > > catname. > > > > > > > > Please advise. Thanks in advance. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---