php - Cakephp handle MySQL enum -


i got enum datatype field in mysql table named "privacy" = enum("public","private","custom"). want show field on edit view like,

<?php      echo $this->form->input(               "privacy",array(                    'label'=>'',                    'type'=>'select'               )          );   ?> 

i tried this link solution found 2 major problems it.

1.) need pass available options view controller , need assign them field in view file.

2.) pass array numeric index, on form submit view pass value's index rather it's value. if select privacy option "custom", view pass 2 not gonna saved in database, cause enum , 2 not valid option.

i thought cakephp smart enough evaluate provided field enum , fetch available options database , handle field on it's own.

is there option in cakephp solves issue or need pass hard coded associative array view?

here code useful select gender enum datatype

in view file

<?php                 echo $form->input('gender', array(                         'type'=>'select',                         'options'=>array("male" => "male", "female" => "female")                     )                 ); 

and controller have initialize

$this->data['profile']['gender'] = $sel_gender['profile']['gender']; 

let me know if can more...


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -