As such
- You can retrieve options from a Model (Database Table).
- Or, you can specify options for select tag in view files.
Just keep in mind CakePHP does not support ENUM type field. So, you may not use 'ENUM' datatype in table fields.
To retrieve options from Database Table
Say, you have two Models (tables) - Order and Size;
Fields in 'sizes' table:
id, size
And fields in 'orders' table:
id, quantity, size_id
In your OrdersController file (/app/controllers/orders_controller.php)
$sizes = $this->Order->Size->find('all');
$this->set('sizes',$sizes);
Now in your view file: (/app/views/orders/add.ctp)
echo $form->create('Order');
echo $form->input('quantity');
echo $form->input('size_id');
echo $form->end('Submit');
And done.
Note the use of variable names.
It is important to name the variables as per this convention. It will display all sizes available in database when you are adding a new order. To retrieve size field in table 'sizes', you need to specify variable name 'sizes' (note plural form) in your respective controller/action. Now when you refer to 'size_id' in view file - cake will create a select tag on the fly with options retrieved from database.
OK. It was pretty simple.
Now, how to display options for HTML Select Tag without any database table:
In this case, we have, say, only 'orders' table with following fields
id, quantity, size
In your view file (/app/views/orders/add.ctp), specify -
$form->create('Order');
$form->input('quantity');
$sizes = array('s'=>'Small', 'm'=>'Medium', 'l'=>'Large');
echo $form->input('size', array('options'=>$sizes, 'default'=>'m'));
$form->end('submit');
That's it.