请帮帮我
这是我的控制器代码
public function actionDynamiclocation()
{
$data=Kegiatan::model()->findAll('nid=:nid',
array(':nid'=>(int) $_POST['nid']));
$data=CHtml::listData($data,'nid','lokasi','pengajuan','realisasi');
foreach($data as $value=>$name)
{
echo CHtml::tag('option',
array('value'=>$value),CHtml::encode($name),true);
}
}
public function actionAjaxCreate() {$model=new Reportbean;
$outlets = Kegiatan::model()->findAll('nid=:nid',
array(':nid'=>(int) $_POST['nid']));
$model->lokasi=0;
$model->pengajuan=1;
$model->realisasi=2;
$this->renderPartial('_keg ', array('model'=>$model),false,true);
}
并查看代码
<div class="row">
<?php echo $form->labelEx($model,'kegiatan'); ?>
<?php echo $form->DropDownList($model,'kegiatan',
array(),
array(
'empty'=>'--pilih--',
'ajax' => array(
'type'=>'POST', //request type
'url'=>CController::createUrl('Reportbean/ajaxCreate'), //url to call.
'data'=>array('nid'=>'js:this.value'),
'update'=>'.outlet',
//'update'=>'#'.CHtml::activeId($model,'lokasi'), //selector to update
//'data'=>array('nid'=>'js:this.value'),
))); ?>
<div class="outlet">
<?php
$this->renderPartial('_keg', array('model'=>$model),false,true);
?>
</div>
<?php
$this->widget('zii.widgets.CDetailView', array(
'data'=>$model,
'id'=>'keg',
'attributes'=>array(
'lokasi',
'pengajuan',
'realisasi',
),
));
?>