Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- echo CHtml::hiddenField('pole_id', '', array('class' => 'span5'));
- $this->widget('ext.select2.ESelect2',array(
- 'id'=>'myselect',
- 'selector' => '#pole_id',
- 'model'=>$model,
- 'attribute'=>'pole_id',
- 'options' => array(
- 'allowClear'=>true,
- 'placeholder'=>'Select a Pole',
- 'minimumInputLength' => 3,
- 'ajax' => array(
- 'url' => Yii::app()->createUrl('jpapoles/poles'),
- 'type'=>'GET',
- 'dataType' => 'json',
- 'quietMillis'=> 100,
- 'data' => 'js: function(text,page) {
- return {
- q: text,
- page_limit: 10,
- page: page,
- };
- }',
- 'results'=>'js:function(data,page) { var more = (page * 10) < data.total; return {results: data, more:more };
- }
- ',
- ),
- ),
- ));
- ?>````
- public function actionPoles()
- {
- $data =Poles::model()->findAll('pole_number like :Nome',array(':Nome'=>"%".$_GET['q']."%"));
- $results = array();
- foreach ($data as $list){
- $results[] = array(
- 'id'=>$list->id,
- 'text'=> $list->pole_number,
- );
- }
- echo CJSON::encode($results);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement