Suppose you have a table of tbl_country
country_name | id
Indonesia | 1
USA | 2
And you want to add your data into a form in your model to show as a dropdown list. Just edit your _form files in your view and add this following code
<div class="row"> <?php echo $form->dropDownList($model,'country_id', CHtml::listData(Country::model()->findAll(), 'id', 'country_name'), array('empty'=>'Select Country'))?> </div>That's just simple to do with yii. Have to try it!..
tak boleh pun.. :(
ReplyDeleteHi but while updating the drop down value is not selected as per the insertion. It displays all the values but not selected value.
ReplyDelete