My Widget in View.php file is
<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();
?>
and My function of getsearchcats in controller is
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);
}
}
but no dropdown is generated and nothing is triggered , console show only write text in params and whole page html is shown in post section How to solve this
Here is an example which i created for my search page
echo CHtml::hiddenField('url','');
$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
'name'=>'searchbox',
'value'=>'',
'source'=>CController::createUrl('/site/autoComplete'),
'options'=>array(
'showAnim'=>'fold',
'minLength'=>'2',
'select'=>'js:function( event, ui ) {
$("#searchbox").val( ui.item.label );
$("#url").val( ui.item.url );
this.form.submit();
return false;
}',
),
'htmlOptions'=>array(
$("#selected_id").val(null); $("#selected_type").val(null);',
'class' => 'input-xxlarge',
'id' => 'appendedInputButtons',
'placeholder' => "Start Search",
),
));
controller
foreach($model as $pub){
$data['value'] = $pub['label'];
$data['label'] = $pub['label'];
$list[] = $data;
}
echo json_encode($list);