您好我正在使用以下代码制作相关的组合框:
在视图中:
<?php
echo $form->dropDownListControlGroup($model, 'DDCode',
CHtml::listData(dds_designations::model()->findAll
(array(
'select'=>'DDCode, DDName',
'distinct'=>true,
)) , 'DDCode', 'DOName')
, array('ajax' => array(
'type' => 'POST', //request type
'url' => CController::createUrl
('OrequestsController/createi')
,
'update' => '#' . CHtml::activeId
($model, 'Designation'),
'data' => array
('DDCode' => 'js:this.value'),
))
);
?>
// Designation which need be dependent on above combobox values
<?php $this->widget('ext.select2.ESelect2',array(
'model'=>$model,
'attribute'=>'Designation',
'data'=>CHtml::listData(Orequests::model()->getdesignations($_GET['r']), 'designation', 'designation',
'htmlOptions'=>array(
'style'=>'width:50%')
)); ?>
在控制器创建操作中:
public function actioncreatei()
{
echo "<option value=''>Select Value</option>";
if (isset($_POST['DDCode']))
{
$ddcode = $_POST['DDCode'];
if ($datalst = Orequests::model()->getdesignations($ddcode) )
{
foreach($datalst as $datar)
{
echo
CHtml::tag('optgroup', array('label'=>$datar['designation']),
CHTML::tag('option', array('value'=>$datar['designation']),
CHtml::encode($datar['designation']),true));
}}}}
Controller动作没有被执行。我在DDCode的组合框中选择后也调试了它,控制器动作事件根本没有被触发。在控制器的accessrules功能中也被授予了许可。不确定是什么错误即时通讯我已经测试了所有的补救措施。 任何想法我在代码中做了什么错误?