Hello,
I am encountering a strange bug while trying to make a form field in order to edit a MySQL ENUM field.
I am currently creating the field like this :
<?php
echo $form->labelEx($model,'role');
echo $form->dropDownList($model,'role', array('user', 'client', 'admin'));
echo $form->error($model,'role');
?>
As you can see, I’ve got a column named role which can be set to user, client or admin.
Then problem is that the dropdown list doesn’t select the current role (I checked $model and it is correctly assigned).
After trying a few things, I think them problem comes from the line 1879 of CHtml.php (code.google.com/p/yii/source/browse/tags/1.1.8/framework/web/helpers/CHtml.php#1879) where $key is a number and my default value, $selection is a string so strcmp always returns -1.
If I replace $key with $value, the problem disappears.
I don’t know if this is a real bug or if I’m just using the wrong approach to set the default value with this control.
Can somebody enlighten me about this issue?
Thanks a lot,
Aweb