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

1.10.x
Angel Fernando Quiroz Campos 10 years ago
parent 9708786334
commit c1741aed37
  1. 11
      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;

Loading…
Cancel
Save