Yii Framework Forum: Yiibooster + Select2Row Error.. Help Me - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yiibooster + Select2Row Error.. Help Me Yiibooster + select2row Error.. help me Rate Topic: -----

#1 User is offline   ThePr0f3550r 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 33
  • Joined: 27-September 12

Posted 03 April 2014 - 08:26 PM

in view
echo $form->select2Row($model, 'employeeId', array(
			'asDropDownList' => false,
			'options' => array(
				'minimumInputLength'=>'1',
				'placeholder' => 'Select employee',
				'allowClear' => false,
				'ajax' => array(
					'url' 		=> Yii::app()->controller->createUrl('general/employee/allData'),
					'dataType' 	=> 'jsonp',
					'data' 		=> 'js:function(term) { return {q: term}; }',
					'results' 	=> 'js:function(data) { return {results: data}; }',
					),
				)
		));


in Controller
public function actionAllData(){
        //if(isset($_GET['q'])){
        
            $queryterm  = @$_GET['q'];
	        $employees    = Employee::model()->findAll(
	        											array(   'order'     => 'name', 
	                                                        	'condition' => 'name LIKE :name', 
	                                                        	'params'    => array(':name'=>$queryterm . '%')
	                                                    )
	                                                   );
	        //$data       = CHtml::listData($employees, 'id', 'name') ;
	        $data = array();
			foreach ($employees as $value) {
				$data[] = array(
				'id' => $value->id,
				'text' => $value->name,
				);
			}
	        echo CJSON::encode($data);
	    //}

	    Yii::app()->end();
	}


Tapi gak keluar apapun.. padahal kalo controller diakses keluar Jsonnya
[{"id":"1","name":"Hafid Mukhlasin"}]
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users