how to set a column values of a table to an activeDropDownList

please explain to do it

my table is holidaymaster and column is holidaytype.

Hey, I was coming up with the same problem. I wondered if anyone answered your question. If they did, post back plz.

lets see if I got what you meant: you want to keep a table of holidays and each holiday has a type, right? If so…

I think that it's better to store the type of holiday in a table instead of using fixed values so you should have a table for this purpose…lets call it HolidayType

  • holidayTypeId

  • holidayTypeDescription

so, in the _form of your HolidayMaster:

<?php

    echo CHtml::activeLabelEx($model,'holidayMasterTypeId');

    echo CHtml::activeDropDownList($model, 'holidayMasterTypeId',

    CHtml::listData(HolidayType::model()->findAll(), 'holidayTypeId', 'holidayTypeDescription', ''), array ( ));

?>

and the trick was done.

tought it's an old topic, hope this helps somebody…

;>))

cheers!!!

Thanks.  well