0

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.

Femme Fatale
  • 870
  • 7
  • 27
  • 56
  • Have you check the [log](http://www.yiiframework.com/doc/guide/1.1/en/topics.logging), it's located in protected\runtime\application.log? Have you put your dropdownlist inside the form? – Iswanto San Feb 10 '14 at 22:54
  • Maybe you need to configure the log. See [this](http://www.yiiframework.com/doc/guide/1.1/en/topics.logging) – Iswanto San Feb 10 '14 at 23:04

1 Answers1

1

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

activeDropDownList() method

Ali MasudianPour
  • 14,329
  • 3
  • 60
  • 62