Let's assume that you are working with Items, each of which is in a category - 
so you need a Category drop down.

In the items_controller action that calls your form, do the following:

$this->set('categories', $this->Item->Category->find('list');

In your view, type this:

echo $this->Form->input('category_id');

Cake will automatically tie up your $categories variable (created by 
this->set('categories', etc...) and use it as the option list for the drop 
down. The stored value will be 'id', the displayed value will be 'name'. This 
does - of course - assume that you have adhered to Cake's table and field 
naming conventions.

Jeremy Burns
Class Outfit

[email protected]
http://www.classoutfit.com

On 15 Jun 2010, at 14:00, Shaz wrote:

> Probably something really simple but I can't figure it out / find
> information on it:
> 
> Got a form (add article) with a drop down list (categories). How do I
> get it to show the category names rather than id while still
> maintaining the id as the value?
> 
> Check out the new CakePHP Questions site http://cakeqs.org and help others 
> with their CakePHP related questions.
> 
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" 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

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" 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

Reply via email to