hi to all, i have 2 dependent drop, its work ok, when i select on the first field and its show on on the second field, but the problem is when error validation, tmy dependent dropdown return to empty
this is my controller code on my dependent
public function actionRoom()
{
$sched = Schedule::model()->findByPk($_POST['MonitoringHdr']['sched_id']);
$data = array();
if($sched != NULL){
$data=Room::model()->findAll('bldg_id=:bldg_id',
array(':bldg_id'=>$sched->bldg_id));
$data=CHtml::listData($data,'id','room');
}else{
echo CHtml::tag('option',
array(),"No rooms available",true);
}
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
my view
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('MonitoringHdr/room'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#room_id', //selector to update
)));?>
echo CHtml::dropDownList('room_id','', array());