activeDropDownList empty element

Hello, I’m confused about easy thing. I have a dropdown list like that:

    <?php  $collect = collections::model()->findAll();  ?>

    <?php echo CHtml::activeLabelEx($model,'Колекція'); ?>

    <?php echo CHtml::activeDropDownList($model, 'collectid', CHtml::listData($collect , 'collectid', 'nameua')); ?>

But I can’t add empty element to the list which would set collectid as NULL and return it to table ‘model’.

Possible way is to create some collection in the table ‘collections’ with defined collectid, smth. like: collectid = 999 and then check returned value in controller and if it would be 999 set it as NULL and then save it into table ‘model’. But it doesn’t seem to be good idea. Tables look like that:








CHtml::activeDropDownList() accepts 4th argument, where you can specify ‘prompt’, ‘empty’ and ‘options’ keys with the adequate array values.

Thank you very much I missed that in class reference! Now it works as it should :)

I need to add 1 more option with the value = 0


<option value="0">Please Select</option>


I make use of the 4th argument, but it only generate


<option value="">Please Select</option>


which course validation error when saved, I need 0 instead empty.

I tried passing a tag as the 4th para,

array(CHtml::tag('option', array('value'=>'0'), 'Please Select'))

nothing in generated. Can you please advice?