\AutocompleteField
AutocompleteField Allow the quick selection of items on the client side and (conventionally) return an ID for ease of use.
- Author: Will Morgan <@willmorgan>
Synopsis
class AutocompleteField
extends FormField
{
- // members
- protected callable $dataSource;
- protected callable $recordFormatter;
- protected FieldList $children;
- protected $autocompleteID;
- protected array $defaultConfig = ;
- protected array $requiredConfig = ;
- protected array $config = ;
- // methods
- public void __construct()
- public void setValue()
- public int|false Value()
- public string getRawValue()
- public DataObject|null getRecord()
- public $this setConfig()
- protected $this setupChildren()
- public void setForm()
- public FieldList getChildren()
- public TextField getRawField()
- public HiddenField getRecordIDField()
- public $this setDataSource()
- public callable getDataSource()
- public DataList getLiveData()
- protected void generateGetLiveData()
- public array getCompleteData()
- protected void getRecordFormatter()
- public void setRecordFormatter()
- protected array formatData()
- public $this setAutocompleteID()
- public string getAutocompleteID()
- protected string generateAutocompleteID()
- public void validate()
- public string Field()
- public void addExtraClass()
- public AutocompleteField setAttribute()
Hierarchy
Extends
- FormField
Members
protected
Methods
protected
- formatData() — Format rows to cut down on the data returned to the frontend.
- generateAutocompleteID() — Generate a unique-ish autocomplete ID for referencing in JSconfig
- generateGetLiveData()
- getRecordFormatter()
- setupChildren() — Set up the child elements
public
- __construct()
- Field()
- Value()
- addExtraClass() — Add the extra class to our child elements too {@inheritdoc}
- getAutocompleteID()
- getChildren()
- getCompleteData() — Translate the data into an array of arrays
- getDataSource()
- getLiveData() — Return a DataList of allowed records
- getRawField()
- getRawValue()
- getRecord()
- getRecordIDField()
- setAttribute() — Set an attribute on the raw field's input element
- setAutocompleteID() — Use this to give a simple name to your autocomplete field, referenced in the JS file. Only really necessary if you want to customise the defaults.
- setConfig()
- setDataSource()
- setForm() — Include our children in the form too {@inheritdoc}
- setRecordFormatter()
- setValue() — {@inheritdoc}
- validate() — {@inheritdoc} If no record is found in the auto complete list, the raw value will be validated against any custom field's constraints.