How to set the default value for activeDropDownList


I have a activeDropDownList in my view,

<div class="row">

<?php echo CHtml::activeLabelEx($model,'status'); ?>

<?php echo CHtml::activeDropDownList($model,'status',Survey::getStatusOptions()); ?>

<?php echo CHtml::error($model,'status'); ?>


getStatusOptions is funciton in my model

class Survey extends CActiveRecord



    const STATUS_PUBLISH=1;

    const STATUS_DRAFT=2;


    public function getStatusOptions()


        return array(self::STATUS_UNPUBLISH=>'Unpublished',self::STATUS_PUBLISH=>'Published',self::STATUS_DRAFT=>'Draft');



how to set option ‘Draft’ is default for activeDropDownList?

Thank you!

As you use the active version of DropDownList, it will be connected to your model attribute. So you can set the default value in your model by adding this:

public $status=self::STATUS_DRAFT;

thank you!

thank you!

it’s work!