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 to create a
> > > > > > 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 [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
-~----------~----~----~----~------~----~------~--~---