在yii 1中的下拉列表中保存另一个字段值而不是id

I have following code in my view

<?php echo $form->dropDownList($model,'p_28',
    CHtml::listData(AdCourt::model()->findAll(),'id','name') ,
    array(
        'class'=>'form-control',
        'style'=>'width:100%;',

        'empty'=>Yii::t('plaint','Суд турини танланг'),
        'ajax' => array(
            'type'=>'POST', //request type
            'url'=>$this->createUrl('getcourts'),
            'update'=>'#ABlockForm_p_29',
        )
    )); ?>

AdCourt takes values from ad_court table. This tables consists of id, name and court_id. I need to save database court_id instead of id.

How can I do it?

The second parameter of listData is the attribute of the items that will be used as the value for the <option> tag. As such to use the court_id instead of the id you should pass it instead:

CHtml::listData(AdCourt::model()->findAll(),'court_id','name')