Thursday, May 17, 2012

Default selected value in a dropdownlist in Yii

Dynamic dropDownList

    <?php echo $form->dropDownList($model,'clientid', CHtml::listData(Client::model()->findAll(), 'code', 'name'), array('empty'=>'--please select--'));
 ?>

Static dropDownList

        <?php echo $form->dropDownList($model, 'active',
        array('1' => 'Active', '2' => 'Inactive'),
        array('empty' => 'Select Activation')
        ); ?>

No comments:

Post a Comment