Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. echo CHtml::hiddenField('pole_id', '', array('class' => 'span5'));
  2. $this->widget('ext.select2.ESelect2',array(
  3. 'id'=>'myselect',
  4. 'selector' => '#pole_id',
  5. 'model'=>$model,
  6. 'attribute'=>'pole_id',
  7. 'options' => array(
  8. 'allowClear'=>true,
  9. 'placeholder'=>'Select a Pole',
  10. 'minimumInputLength' => 3,
  11.  
  12. 'ajax' => array(
  13. 'url' => Yii::app()->createUrl('jpapoles/poles'),
  14. 'type'=>'GET',
  15. 'dataType' => 'json',
  16. 'quietMillis'=> 100,
  17. 'data' => 'js: function(text,page) {
  18. return {
  19. q: text,
  20. page_limit: 10,
  21. page: page,
  22. };
  23.  
  24. }',
  25.  
  26. 'results'=>'js:function(data,page) { var more = (page * 10) < data.total; return {results: data, more:more };
  27.  
  28. }
  29.  
  30. ',
  31. ),
  32.  
  33. ),
  34.  
  35. ));
  36.  
  37.  
  38. ?>````
  39.  
  40.  
  41. public function actionPoles()
  42. {
  43. $data =Poles::model()->findAll('pole_number like :Nome',array(':Nome'=>"%".$_GET['q']."%"));
  44.  
  45. $results = array();
  46.  
  47. foreach ($data as $list){
  48.  
  49. $results[] = array(
  50.  
  51. 'id'=>$list->id,
  52.  
  53. 'text'=> $list->pole_number,
  54.  
  55. );
  56.  
  57. }
  58.  
  59.  
  60. echo CJSON::encode($results);
  61.  
  62.  
  63.  
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement