Femme Fatale
Femme Fatale

Reputation: 880

Saving data from dropdown list Yii

I am trying to save values from dropdown list into my table column role.
form

<?php echo CHtml::dropDownList('role', $model, $model->getRoleOptions(),
                array('empty' => '---select role---'));
            ?>

model

public function getRoleOptions(){
    return array('1' => 'Administrator', '2' => 'Center Administrator');
}

The value is not being saved. I have also declared role as safe.

Upvotes: 0

Views: 653

Answers (1)

Ali MasudianPour
Ali MasudianPour

Reputation: 14459

Use activeDropDownList() instead of dropDownList(). If you get a dump from your post request, you probably see invalid $_POST value with dropDownList().

activeDropDownList() method

Upvotes: 1

Related Questions