2
我的Widget在View.php文件Yii的CjuiAutoComplete不工作怎麼解決這個錯誤
<div class="modal-body" id="test_modal" style="display: none;">
<?php
$recipeModel = new Recipe();
$form = $this->beginWidget('CActiveForm', array(
'id' => 'user-form',
'enableAjaxValidation' => true,
//'focus'=>array($model,'firstName'),
));
$modelCat = new Category;
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'model' => $modelCat,
'name' => 'cat_name',
'source' => 'Category/getsearchcats',
'options' => array(
'minLength' => '1',
),
'htmlOptions' => array(
'style' => 'height:20px;',
),
));
//
echo '<p id="getdatevalue">One fine body...</p>';
$this->endWidget();
?>
和我的控制器getsearchcats的功能是
public function actiongetsearchcats() {
$request = trim($_GET['term']);
if ($request != '') {
$model = Category::model()->findAll(array("condition" => "cat_name like '$request%'"));
$data = array();
foreach ($model as $get) {
$data[] = $get->cat_name;
}
// $this->layout = 'empty';
echo json_encode($data);
}
}
但不產生下拉菜單並沒有被觸發時,控制檯顯示只寫在PARAMS和整個頁面HTML文本中後段 顯示如何解決這個
'源'=> '類別/ getsearchcats',替換 'sourceUrl'=>數組( '類別/ getsearchcats'), – user1852788