mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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).
This commit is contained in:
parent
8d38551297
commit
1a91431d39
@ -156,7 +156,7 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
*/
|
||||
public function getURLHandlers($gridField) {
|
||||
return array(
|
||||
'search/$ID' => 'doSearch',
|
||||
'search' => 'doSearch',
|
||||
);
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
||||
|
||||
// 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');
|
||||
|
@ -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 ) {
|
||||
|
@ -15,7 +15,7 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
|
||||
$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 @@ class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
|
||||
$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
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user