PageRenderTime 41ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/atk4-addons/mvc/Form/Field/autocomplete.php

https://github.com/git86/todo
PHP | 44 lines | 33 code | 7 blank | 4 comment | 6 complexity | 32571ee99f48e9a082c9281f5e0241b0 MD5 | raw file
Possible License(s): AGPL-3.0
  1. <?php
  2. /*
  3. * Text input with autocomplete
  4. */
  5. class Form_Field_autocomplete extends Form_Field_reference {
  6. function render(){
  7. parent::render();
  8. $js=$this->js(true)
  9. ->_load('ui.combobox')
  10. ->atk4_reference('initAutocomplete',$this->getAutocompleteOptions())
  11. ;
  12. if($this->allowAdd())$this->addPluss($js);
  13. }
  14. function addPluss($js){
  15. $forms_name=$this->owner->getController();
  16. $title=null;
  17. $my_name=$this->short_name;
  18. if(isset($forms_name)){
  19. $title=$this->caption;
  20. //$forms_name->getField($my_name)->caption();
  21. $forms_name=$forms_name->short_name;
  22. }
  23. if(($this->urlForAdding() || method_exists($this->dictionary(),'addDefaultEntity')) && $this->allowAdd()){
  24. $js->atk4_reference('setPlusUrl',
  25. $this->api->getDestinationURL($this->urlForAdding(),
  26. array(
  27. 'cut_region'=>'Content',
  28. 'form_ctl'=>$forms_name,
  29. 'my_name'=>$my_name,
  30. ),false),array('height'=>'500'),$title);
  31. }
  32. }
  33. function getAutocompleteOptions(){
  34. if($this->short_name=='vat_rate_id')return array();
  35. return array('width'=>'200px');
  36. }
  37. }