Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Query param searches for GridFieldAddExistingAutocompleter

Fixes issues with query construction in JS when the search URL
already contains GET paramters (e.g. when using the 'translatable'
module).
  • Loading branch information...
commit 1a91431d39dce6eaa2dd60fa17977693a30fec8f 1 parent 8d38551
@chillu chillu authored
View
4 forms/gridfield/GridFieldAddExistingAutocompleter.php
@@ -156,7 +156,7 @@ public function getManipulatedData(GridField $gridField, SS_List $dataList) {
*/
public function getURLHandlers($gridField) {
return array(
- 'search/$ID' => 'doSearch',
+ 'search' => 'doSearch',
);
}
@@ -181,7 +181,7 @@ public function doSearch($gridField, $request) {
// TODO Replace with DataList->filterAny() once it correctly supports OR connectives
foreach($searchFields as $searchField) {
- $stmts[] .= sprintf('"%s" LIKE \'%s%%\'', $searchField, $request->param('ID'));
+ $stmts[] .= sprintf('"%s" LIKE \'%s%%\'', $searchField, Convert::raw2sql($request->getVar('gridfield_relationsearch')));
}
$results = $allList->where(implode(' OR ', $stmts))->subtract($gridField->getList());
$results = $results->sort($searchFields[0], 'ASC');
View
2  javascript/GridField.js
@@ -301,7 +301,7 @@
"X-Pjax" : 'Partial'
},
type: "GET",
- url: suggestionUrl+'/'+request.term,
+ url: suggestionUrl,
data: form.serialize()+'&'+escape(searchField.attr('name'))+'='+escape(searchField.val()),
success: function(data) {
response( $.map(JSON.parse(data), function( name, id ) {
View
4 tests/forms/gridfield/GridFieldAddExistingAutocompleterTest.php
@@ -15,7 +15,7 @@ function testSearch() {
$btns = $parser->getBySelector('.ss-gridfield #action_gridfield_relationfind');
$response = $this->post(
- 'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield/search/Team 2',
+ 'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield/search/?gridfield_relationsearch=Team 2',
array(
(string)$btns[0]['name'] => 1
)
@@ -26,7 +26,7 @@ function testSearch() {
$this->assertEquals(array($team2->ID => 'Team 2'), $result);
$response = $this->post(
- 'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield/search/Unknown',
+ 'GridFieldAddExistingAutocompleterTest_Controller/Form/field/testfield/search/?gridfield_relationsearch=Unknown',
array(
(string)$btns[0]['name'] => 1
)
Please sign in to comment.
Something went wrong with that request. Please try again.