Dropdownlist() Value

Hi,

I need to know when an option is selected in dropdownlist its corresponding value id need to be stored in database.

I have two tables.

Department

dept_id

dept_name

Access

acl_id

dept_id

I did changes such as the department names are displayed in Access _form.php. When I’m selecting department name from dropdownlist.It shows “Department cannot be blank”.I need to store that corresponding department id value in Access table.

Can anybody help over??

Thanks in advance :)

In the Access form, add this for selecting department




<?php echo $form->labelEx($model,'dept_id'); ?>

<?php echo $form->dropDownList($model,'dept_id',CHtml::listData(Department::model()->findAll(), 'dept_id', 'dept_name'),array('empty'=>'Select')); ?>

<?php echo $form->error($model,'dept_id'); ?>



Thanks.

Thanks. It works.