Browse Source

Add attribute to SelectAjax for generar the search URL by a function

Angel Fernando Quiroz Campos 9 years ago
parent
commit
c1741aed37
1 changed files with 10 additions and 1 deletions
  1. 10 1
      main/inc/lib/formvalidator/Element/SelectAjax.php

+ 10 - 1
main/inc/lib/formvalidator/Element/SelectAjax.php

@@ -66,6 +66,14 @@ class SelectAjax extends HTML_QuickForm_select
             $this->setAttribute('id', $id);
         }
 
+        $url = $this->getAttribute('url');
+
+        if (!$url) {
+            $url = $this->getAttribute('url_function');
+        } else {
+            $url = "'$url'";
+        }
+
         $html .= <<<JS
             <script>
                 $(function(){
@@ -76,7 +84,7 @@ class SelectAjax extends HTML_QuickForm_select
                         width: '$width',
                         minimumInputLength: '$minimumInputLength',
                         ajax: {
-                            url: '{$this->getAttribute('url')}',
+                            url: $url,
                             dataType: 'json',
                             data: function(params) {
                                 return {
@@ -102,6 +110,7 @@ JS;
         $this->removeAttribute('placeholder');
         $this->removeAttribute('class');
         $this->removeAttribute('url');
+        $this->removeAttribute('url_function');
         $this->setAttribute('style', 'width: 100%;');
 
         return parent::toHtml() . $html;