mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Make the list used for autocomplete search results settable.
This is useful if you want to limit the autocomplete results to a subset of all available objects.
This commit is contained in:
parent
3efdb5c981
commit
f5b25d2dff
@ -21,6 +21,11 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
|||||||
*/
|
*/
|
||||||
protected $targetFragment;
|
protected $targetFragment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SS_List
|
||||||
|
*/
|
||||||
|
protected $searchList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Which columns that should be used for doing a "StartsWith" search.
|
* Which columns that should be used for doing a "StartsWith" search.
|
||||||
* If multiple fields are provided, the filtering is performed non-exclusive.
|
* If multiple fields are provided, the filtering is performed non-exclusive.
|
||||||
@ -167,8 +172,12 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
|||||||
* @param SS_HTTPRequest $request
|
* @param SS_HTTPRequest $request
|
||||||
*/
|
*/
|
||||||
public function doSearch($gridField, $request) {
|
public function doSearch($gridField, $request) {
|
||||||
$dataClass = $gridField->getList()->dataClass();
|
if($this->searchList) {
|
||||||
$allList = DataList::create($dataClass);
|
$allList = $this->searchList;
|
||||||
|
} else {
|
||||||
|
$allList = DataList::create($gridField->getList()->dataClass());
|
||||||
|
}
|
||||||
|
|
||||||
$filters = array();
|
$filters = array();
|
||||||
$stmts = array();
|
$stmts = array();
|
||||||
|
|
||||||
@ -209,6 +218,16 @@ class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridF
|
|||||||
return $this->resultsFormat;
|
return $this->resultsFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the base list instance which will be used for the autocomplete
|
||||||
|
* search.
|
||||||
|
*
|
||||||
|
* @param SS_List $list
|
||||||
|
*/
|
||||||
|
public function setSearchList(SS_List $list) {
|
||||||
|
$this->searchList = $list;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Array
|
* @param Array
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user