trait SearchableDropdownTrait (View source)

Properties

Methods

public
search(HTTPRequest $request)

Returns a JSON string of options for lazy loading.

public
bool
getIsClearable()

Get whether the currently selected value(s) can be cleared

public
setIsClearable(bool $isClearable)

Set whether the currently selected value(s) can be cleared

public
bool
getIsLazyLoaded()

Get whether values are lazy loading via AJAX

public
setIsLazyLoaded(bool $isLazyLoaded)

Set whether values are lazy loaded via AJAX

public
int
getLazyLoadLimit()

Get the limit of items to lazy load

public
setLazyLoadLimit(int $lazyLoadLimit)

Set the limit of items to lazy load

public
string
getPlaceholder()

Get the placeholder text

public
setPlaceholder(string $placeholder)

Set the placeholder text

public
SearchContext|null
getSearchContext()

Get the search context to use If a search context has been set via setSearchContext() that will be used Will fallback to using the dataobjects default search context if a sourceList has been set Otherwise will return null

public
setSearchContext(SearchContext|null $searchContext)

Set the search context to use instead of the dataobjects default search context

public
bool
getUseDynamicPlaceholder()

Get whether to use a dynamic placeholder if a normal placeholder is not set

public
setUseDynamicPlaceholder(bool $useDynamicPlaceholder)

Set whether to use a dynamic placeholder if a normal placeholder is not set

public
bool
getUseSearchContext()

Get whether to use a search context instead searching on labelField

public
setUseSearchContext(bool $useSearchContext)

Set whether to use a search context instead searching on labelField

public
bool
getIsSearchable()

Get whether the field allows searching by typing characters into field

public
setIsSearchable(bool $isSearchable)

Set whether the field allows searching by typing characters into field

public
array
getSource()

This returns an array rather than a DataList purely to retain compatibility with ancestor getSource()

public
setSource($source)

No description

public
string
getLabelField()

Get the field to use for the label of the option

public
setLabelField(string $labelField)

Set the field to use for the label of the option

public
array
getAttributes()

No description

public
array
getValueArray()

Get a list of selected ID's

public
void
saveInto(DataObjectInterface $record)

No description

public
bool
validate(Validator $validator)

No description

public
string
getSchemaDataType()

No description

public
array
getSchemaDataDefaults()

Provide data to the JSON schema for the frontend component

public
array
getSchemaStateDefaults()

No description

protected
setIsMultiple(bool $isMultiple)

Set whether the field allows multiple values This is only intended to be called from init() by implemented classes, and not called directly To instantiate a dropdown where only a single value is allowed, use SearchableDropdownField.

Details

Returns a JSON string of options for lazy loading.

Parameters

HTTPRequest $request

Return Value

HTTPResponse

bool getIsClearable()

Get whether the currently selected value(s) can be cleared

Return Value

bool

SearchableDropdownTrait setIsClearable(bool $isClearable)

Set whether the currently selected value(s) can be cleared

Parameters

bool $isClearable

Return Value

SearchableDropdownTrait

bool getIsLazyLoaded()

Get whether values are lazy loading via AJAX

Return Value

bool

SearchableDropdownTrait setIsLazyLoaded(bool $isLazyLoaded)

Set whether values are lazy loaded via AJAX

Parameters

bool $isLazyLoaded

Return Value

SearchableDropdownTrait

int getLazyLoadLimit()

Get the limit of items to lazy load

Return Value

int

SearchableDropdownTrait setLazyLoadLimit(int $lazyLoadLimit)

Set the limit of items to lazy load

Parameters

int $lazyLoadLimit

Return Value

SearchableDropdownTrait

string getPlaceholder()

Get the placeholder text

Return Value

string

SearchableDropdownTrait setPlaceholder(string $placeholder)

Set the placeholder text

Calling this will also call setHasEmptyDefault(true), if the method exists on the class, which is required for the placeholder functionality to work on SearchableDropdownField

In the case of SearchableDropField this method should be used instead of setEmptyString() which will be remvoved in a future version

Parameters

string $placeholder

Return Value

SearchableDropdownTrait

SearchContext|null getSearchContext()

Get the search context to use If a search context has been set via setSearchContext() that will be used Will fallback to using the dataobjects default search context if a sourceList has been set Otherwise will return null

Return Value

SearchContext|null

SearchableDropdownTrait setSearchContext(SearchContext|null $searchContext)

Set the search context to use instead of the dataobjects default search context

Calling this will also call setUseSearchContext(true)

Parameters

SearchContext|null $searchContext

Return Value

SearchableDropdownTrait

bool getUseDynamicPlaceholder()

Get whether to use a dynamic placeholder if a normal placeholder is not set

Return Value

bool

SearchableDropdownTrait setUseDynamicPlaceholder(bool $useDynamicPlaceholder)

Set whether to use a dynamic placeholder if a normal placeholder is not set

Parameters

bool $useDynamicPlaceholder

Return Value

SearchableDropdownTrait

bool getUseSearchContext()

Get whether to use a search context instead searching on labelField

Return Value

bool

SearchableDropdownTrait setUseSearchContext(bool $useSearchContext)

Set whether to use a search context instead searching on labelField

Parameters

bool $useSearchContext

Return Value

SearchableDropdownTrait

bool getIsSearchable()

Get whether the field allows searching by typing characters into field

Return Value

bool

SearchableDropdownTrait setIsSearchable(bool $isSearchable)

Set whether the field allows searching by typing characters into field

Parameters

bool $isSearchable

Return Value

SearchableDropdownTrait

array getSource()

This returns an array rather than a DataList purely to retain compatibility with ancestor getSource()

Return Value

array

SearchableDropdownTrait setSource($source)

No description

Parameters

$source

Return Value

SearchableDropdownTrait

string getLabelField()

Get the field to use for the label of the option

The default value of 'Title' will map to DataObject::getTitle() if a Title DB field does not exist

Return Value

string

SearchableDropdownTrait setLabelField(string $labelField)

Set the field to use for the label of the option

Parameters

string $labelField

Return Value

SearchableDropdownTrait

array getAttributes()

No description

Return Value

array

array getValueArray()

Get a list of selected ID's

Return Value

array

void saveInto(DataObjectInterface $record)

No description

Parameters

DataObjectInterface $record

Return Value

void

bool validate(Validator $validator)

No description

Parameters

Validator $validator

Return Value

bool

string getSchemaDataType()

No description

Return Value

string

array getSchemaDataDefaults()

Provide data to the JSON schema for the frontend component

Return Value

array

array getSchemaStateDefaults()

No description

Return Value

array

protected SearchableDropdownTrait setIsMultiple(bool $isMultiple)

Set whether the field allows multiple values This is only intended to be called from init() by implemented classes, and not called directly To instantiate a dropdown where only a single value is allowed, use SearchableDropdownField.

To instantiate a dropdown where multiple values are allowed, use SearchableMultiDropdownField

Parameters

bool $isMultiple

Return Value

SearchableDropdownTrait