Newbie question about dropdown list

i have a simple dropDownList using CHtml my problem is how would i catch the value of the selected item?

it return me only the index of the selected item.

What do you want to achieve? Can you post some code?

Well, assuming you just want to return the name to the controller, you can do the either of the following:

  1. Change the CHtml::listData in your dropdown code

Normally you would do something like this:




CHtml::listData(ExampleModel::model()->findAll(), 'FieldID', 'FieldName')



You could change it to this:




CHtml::listData(ExampleModel::model()->findAll(), 'FieldName', 'FieldName')



Although doing it this way, you would not get the previous selection highlighted without some additional manipulation to the dropDownList

  1. Do the lookup in the controller



$data=ExampleModel::model()->find('FieldID=:id', array(':id'=>(int)$_POST['SomeModel']['SomeID']));

$theName = $data->FieldName;



Something like that…

Hope this helps. Like mentel said, maybe with some additional information and code we could better help you out.

THX!

-g.