Hello Yii Community!
I have a bit of trouble in updating my form in dropdown,
This is partial view code
<div class="row">
<?php if($users->isNewRecord) {
echo $form->labelEx($departments,'dept_name');
$data = Departments::model()->findAll(array('order'=>'dept_name'));
$data = CHtml::listData($data,'dept_id','dept_name');
echo CHtml::dropDownList('department', $departments,$data,
array(
'prompt'=>'Select Department',
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('updatesection'),
'update'=>'#Sections_sec_name',
)));
} else {
echo $form->labelEx($departments,'dept_name');
$data = Departments::model()->findAll(array('order'=>'dept_name'));
$data = CHtml::listData($data,'dept_id','dept_name');
echo CHtml::dropDownList('department', $departments,$data,
array(
'prompt'=>'Select Department',
'options' => array($users->userSec->secDept->dept_id=>array('selected'=>true),
'ajax' => array(
'type'=>'POST',
'url'=>CController::createUrl('updatesection'),
'update'=>'#Sections_sec_name',
))));
}
?>
</div>
<div class="row">
<?php echo $form->labelEx($sections,'sec_name'); ?>
<?php echo $form->dropDownList($sections,'sec_name',
array('empty'=>'Select Sections..',
));
?>
</div>
In department dropdown list, the data will be based on the save values on the database as well the section.
But if the department dropdown is changed the ajax won’t work like in the Create Form.
What seems to be the problem. Thanks for the help!