class GridFieldAddExistingAutocompleter implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator, GridField_URLHandler

This class is is responsible for adding objects to another object's has_many and many_many relation, as defined by the {@link RelationList} passed to the {@link GridField} constructor.

Objects can be searched through an input field (partially matching one or more fields).

Selecting from the results will add the object to the relation.

Often used alongside {@link GridFieldDeleteAction} for detaching existing records from a relationship.

For easier setup, have a look at a sample configuration in {@link GridFieldConfig_RelationEditor}.

Methods

__construct(string $targetFragment = 'before', array $searchFields = null)

No description

array
getHTMLFragments(GridField $gridField)

No description

array
getActions(GridField $gridField)

No description

handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

Manipulate the state to add a new relation

getManipulatedData(GridField $gridField, SS_List $dataList)

If an object ID is set, add the object to the list

array
getURLHandlers(GridField $gridField)

No description

string
doSearch(GridField $gridField, HTTPRequest $request)

Returns a json array of a search results that can be used by for example Jquery.ui.autosuggestion

$this
setResultsFormat(string $format)

No description

string
getResultsFormat()

No description

setSearchList(SS_List $list)

Sets the base list instance which will be used for the autocomplete search.

$this
setSearchFields(array $fields)

No description

array
getSearchFields()

No description

array|null
scaffoldSearchFields(string $dataClass)

Detect searchable fields and searchable relations.

string
getPlaceholderText(string $dataClass)

No description

$this
setPlaceholderText(string $text)

No description

int
getResultsLimit()

Gets the maximum number of autocomplete results to display.

$this
setResultsLimit(int $limit)

No description

Details

at line 93
__construct(string $targetFragment = 'before', array $searchFields = null)

Parameters

string $targetFragment
array $searchFields Which fields on the object in the list should be searched

at line 104
array getHTMLFragments(GridField $gridField)

Parameters

GridField $gridField

Return Value

array

at line 160
array getActions(GridField $gridField)

Parameters

GridField $gridField

Return Value

array with action identifier strings.

at line 173
handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

Manipulate the state to add a new relation

Parameters

GridField $gridField
string $actionName Action identifier, see {@link getActions()}.
array $arguments Arguments relevant for this
array $data All form data

at line 191
SS_List getManipulatedData(GridField $gridField, SS_List $dataList)

If an object ID is set, add the object to the list

Parameters

GridField $gridField
SS_List $dataList

Return Value

SS_List

at line 210
array getURLHandlers(GridField $gridField)

Parameters

GridField $gridField

Return Value

array

at line 224
string doSearch(GridField $gridField, HTTPRequest $request)

Returns a json array of a search results that can be used by for example Jquery.ui.autosuggestion

Parameters

GridField $gridField
HTTPRequest $request

Return Value

string

at line 275
$this setResultsFormat(string $format)

Parameters

string $format

Return Value

$this

at line 284
string getResultsFormat()

Return Value

string

at line 295
setSearchList(SS_List $list)

Sets the base list instance which will be used for the autocomplete search.

Parameters

SS_List $list

at line 305
$this setSearchFields(array $fields)

Parameters

array $fields

Return Value

$this

at line 314
array getSearchFields()

Return Value

array

at line 327
array|null scaffoldSearchFields(string $dataClass)

Detect searchable fields and searchable relations.

Falls back to {@link DataObject->summaryFields()} if no custom search fields are defined.

Parameters

string $dataClass The class name

Return Value

array|null names of the searchable fields

at line 366
string getPlaceholderText(string $dataClass)

Parameters

string $dataClass The class of the object being searched for

Return Value

string

at line 406
$this setPlaceholderText(string $text)

Parameters

string $text

Return Value

$this

at line 417
int getResultsLimit()

Gets the maximum number of autocomplete results to display.

Return Value

int

at line 427
$this setResultsLimit(int $limit)

Parameters

int $limit

Return Value

$this