diff --git a/Datatable/Ajax.php b/Datatable/Ajax.php index cc9939db..de1bdd1d 100644 --- a/Datatable/Ajax.php +++ b/Datatable/Ajax.php @@ -43,7 +43,7 @@ class Ajax * * @var string */ - protected $type; + protected $method; /** * Data to be sent. @@ -90,17 +90,17 @@ public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults(array( 'url' => null, - 'type' => 'GET', + 'method' => 'GET', 'data' => null, 'pipeline' => 0, )); $resolver->setAllowedTypes('url', array('null', 'string')); - $resolver->setAllowedTypes('type', 'string'); + $resolver->setAllowedTypes('method', 'string'); $resolver->setAllowedTypes('data', array('null', 'array')); $resolver->setAllowedTypes('pipeline', 'int'); - $resolver->setAllowedValues('type', array('GET', 'POST')); + $resolver->setAllowedValues('method', array('GET', 'POST')); return $this; } @@ -134,29 +134,49 @@ public function setUrl($url) } /** - * Get type. + * Get method. * * @return string */ + public function getMethod() + { + return $this->method; + } + + /** + * @return string + * @deprecated Use getMethod() instead + */ public function getType() { - return $this->type; + return $this->getMethod(); } /** - * Set type. + * Set method. * - * @param string $type + * @param string $method * * @return $this */ - public function setType($type) + public function setMethod($method) { - $this->type = $type; + $this->method = $method; return $this; } + /** + * @param $method + * + * @return \Sg\DatatablesBundle\Datatable\Ajax + * @deprecated Use setMethod() instead + */ + public function setType($method) + { + return $this->setMethod($method); + } + /** * Get data. * diff --git a/Resources/public/js/pipeline.js b/Resources/public/js/pipeline.js index 83085bf1..5a7a2c66 100644 --- a/Resources/public/js/pipeline.js +++ b/Resources/public/js/pipeline.js @@ -5,7 +5,7 @@ $.fn.dataTable.pipeline = function ( opts ) { url: '', // script url data: null, // function or object with parameters to send to the server // matching how `ajax.data` works in DataTables - method: 'GET' // Ajax HTTP method + method: opts.method // Ajax HTTP method }, opts ); // Private variables for storing the cache @@ -73,7 +73,7 @@ $.fn.dataTable.pipeline = function ( opts ) { } settings.jqXHR = $.ajax( { - "type": conf.method, + "method": conf.method, "url": conf.url, "data": request, "dataType": "json", diff --git a/Resources/views/datatable/ajax.html.twig b/Resources/views/datatable/ajax.html.twig index fd6b6504..97a4a10f 100644 --- a/Resources/views/datatable/ajax.html.twig +++ b/Resources/views/datatable/ajax.html.twig @@ -10,7 +10,7 @@ {% if sg_datatables_view.ajax.url is not same as(null) %} "url": "{{ sg_datatables_view.ajax.url|raw }}", {% endif %} - "type": "{{ sg_datatables_view.ajax.type }}", + "method": "{{ sg_datatables_view.ajax.method }}", {% if sg_datatables_view.ajax.data is not same as(null) %} "data": {{ sg_datatables_view.ajax.data|raw }}, {% endif %} @@ -27,6 +27,3 @@ {{ ajax_vars }} }, {% endif %} - - - diff --git a/Resources/views/datatable/multiselect_actions.html.twig b/Resources/views/datatable/multiselect_actions.html.twig index dab2ef53..82d68fc8 100644 --- a/Resources/views/datatable/multiselect_actions.html.twig +++ b/Resources/views/datatable/multiselect_actions.html.twig @@ -162,7 +162,7 @@ $(".sg-datatables-{{ datatable_name }}-multiselect-action").on("click", function if (url != null) { $.ajax({ url: url, - type: "POST", + method: "POST", cache: false, data: { 'data': items, diff --git a/Response/DatatableResponse.php b/Response/DatatableResponse.php index 4bbb8b91..2588662d 100644 --- a/Response/DatatableResponse.php +++ b/Response/DatatableResponse.php @@ -193,7 +193,7 @@ private function createDatatableQueryBuilder() private function getRequestParams() { $parameterBag = null; - $type = $this->datatable->getAjax()->getType(); + $type = $this->datatable->getAjax()->getMethod(); if ('GET' === strtoupper($type)) { $parameterBag = $this->request->query; diff --git a/Tests/Datatables/PostDatatable.php b/Tests/Datatables/PostDatatable.php index 68247977..753dbedb 100644 --- a/Tests/Datatables/PostDatatable.php +++ b/Tests/Datatables/PostDatatable.php @@ -28,7 +28,7 @@ public function buildDatatable(array $options = array()) { $this->ajax->set(array( 'url' => '', - 'type' => 'GET', + 'method' => 'GET', )); $this->options->set(array(