SelectRemoteSearch.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\AjaxFields;
  3. use ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates;
  4. /**
  5. * Select field controler
  6. *
  7. * @autor ThurData <info@thurdata.ch>
  8. */
  9. class SelectRemoteSearch extends Select
  10. {
  11. protected $id = 'ajaxSelectRemoteSearch';
  12. protected $name = 'ajaxSelectRemoteSearch';
  13. protected $vueComponent = true;
  14. protected $defaultVueComponentName = 'mg-ajax-select-rs';
  15. /**
  16. * do not overwrite this function
  17. * @return type \ThurData\Servers\KerioEmail\Core\UI\ResponseTemplates\RawDataJsonResponse
  18. */
  19. public function returnAjaxData()
  20. {
  21. $this->prepareAjaxData();
  22. $returnData = [
  23. 'options' => $this->getAvailableValues()
  24. ];
  25. return (new ResponseTemplates\RawDataJsonResponse($returnData))->setCallBackFunction($this->callBackFunction);
  26. }
  27. /**
  28. * overwrite this function, use setSelectedValue && setAvailableValues functions
  29. */
  30. public function prepareAjaxData()
  31. {
  32. $this->setAvailableValues([
  33. ['key' => '1', 'value' => 'value1'],
  34. ['key' => '2', 'value' => 'value2']
  35. ]);
  36. }
  37. public function initContent()
  38. {
  39. }
  40. }