php - How to set a value fetched from database table as selected value in drop down list in cakephp? -


hey trying set selected="selected" drop down list cant seem solution.

e.g.. city entered in user's table when user chooses edit profile rest of details comes in text boxes city should displayed in drop down list , default selected value should match city of user.

note :- citites entered directly in

echo $this->form->input("city",array("type"=>"select","empty"=‌​>"city","options"=>a‌​rray("city1"=>"city1‌​","city2"=>"city2","‌​city3"=>"city3","cit‌​y4"=>"city4"))); 

you can use default make option selected in cakephp

try this:

echo $this->form->input('city', array('type' => 'select', 'options' => array("city1"=>"city1‌​","city2"=>"city2","‌​city3"=>"city3","cit‌​y4"=>"city4"), "default" => "city1")); 

Comments

Popular posts from this blog

cookies - Yii2 Advanced - Share session between frontend and mainsite (duplicate of frontend for www) -

angular - password and confirm password field validation angular2 reactive forms -

php - Permission denied. Laravel linux server -