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

Loading…
Cancel
Save