Reputation: 10412
I have enum function in some of the rows and was wondering how we could fetch this in Cake to view it as select box?
Below is the function example:
enum('Uusi hakija','Jatkohakemus','40+','60+','Työyhteisöhanke','Mieshanke','Urheiluseurahanke')
Upvotes: 0
Views: 393
Reputation: 14798
The proper "Cake" way of doing this would be to use the Array Datasource from the official datasources plugin.
You setup a model for your enum data and assign all the normal relationships. To set the data set the records property in your model like so:
public $records = array(
array('id' => '1', 'name' => 'stuff'),
array('id' => '2')
);
Upvotes: 1
Reputation: 7853
$enumList = enum('Your', 'stuff', 'goes', 'here');
$vars = explode('.', $enumList);
$this->Form->select('Model.field_name', $vars);
Very simple but should work. Your option
names would be 0
, 1
, 2
, etc.
Check out CakePHP's FormHelper and the select
input.
Upvotes: 0