我的 2 个相关下拉菜单考试类型和状态工作正常,它们显示值..但这些值没有设置到数据库中..请帮助我...这是我的代码
表单视图:
<tr>
<td><?php echo $form->labelEx($model,'exam type :'); ?></td>
<td>
<?php echo CHtml::dropDownList('exam_type','',CHtml::listData(class1::model()->findAll(),'class','class'),array('empty'=>'Choose one',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('dynamicstates'), //url to call.
//Style: CController::createUrl('currentController/methodToCall')
'update'=>'#status', //selector to update
)));
//empty since it will be filled by the other dropdown
?>
</td>
<td> <?php echo $form->error($model,'exam_type'); ?></td>
</tr>
<tr>
<td><?php echo $form->labelEx($model,'status :'); ?></td>
<td><?php echo CHtml::dropDownList('status','', array());?></td>
<td> <?php echo $form->error($model,'status'); ?></td>
</tr>
控制器视图:
public function actiondynamicstates()
{
echo $aasd=$_POST['exam_type'];
echo $data=admission::model()->findAll('class=:class',
array(':class'=>$aasd));
$data=CHtml::listData($data,'studentid','studentfname');
foreach($data as $value=>$name)
echo CHtml::tag('option', array('value'=>$value), CHtml::encode($name), true);
}