SilverWare\Select2\Forms\Select2AjaxField
An extension of the Select2 field class for a Select2 Ajax field.
- Author: Colin Tucker <colin@praxis.net.au>
- Copyright: 2017 Praxis Interactive
- License: https://opensource.org/licenses/BSD-3-Clause BSD-3-Clause
Synopsis
class Select2AjaxField
extends Select2Field
{
- // members
- private static array $allowed_actions = ;
- private static array $default_ajax_config = ;
- private static array $default_config = ;
- protected $ajaxConfig;
- protected boolean $ajaxEnabled = true;
- protected string $dataClass = SiteTree::class;
- protected string $idField = 'ID';
- protected string $textField = 'Title';
- protected array $searchFields = ;
- protected array|string $sortBy = ;
- protected integer $limit = 256;
- protected array $exclude = ;
- protected $formatResult;
- protected $formatSelection;
- // methods
- public void __construct()
- public string Type()
- public $this setSource()
- public $this setAjaxConfig()
- public mixed getAjaxConfig()
- public $this setAjaxEnabled()
- public boolean getAjaxEnabled()
- public $this setDataClass()
- public string getDataClass()
- public $this setIDField()
- public string getIDField()
- public $this setTextField()
- public string getTextField()
- public $this setSearchFields()
- public array getSearchFields()
- public $this setSortBy()
- public array getSortBy()
- public $this setLimit()
- public integer getLimit()
- public $this setExclude()
- public array getExclude()
- public $this setFormatResult()
- public string getFormatResult()
- public $this setFormatSelection()
- public string getFormatSelection()
- public $this setDescriptor()
- public array getDataAttributes()
- public boolean isAjaxEnabled()
- public HTTPResponse search()
- public array getSearchFilters()
- public string getSearchFilterName()
- public void loadFromRelation()
- public void saveIntoRelation()
- public boolean isSelectedValue()
- public array getSourceEmpty()
- protected ViewableData getValueRecord()
- protected HTTPResponse respond()
- protected SS_List getList()
- protected array getResultData()
- protected string getFormattedResult()
- protected string getFormattedSelection()
- protected array getListMap()
- protected array getFieldConfig()
- protected array getFieldAjaxConfig()
- // Inherited methods from Select2Field
- public void __construct()
- public string Type()
- public DBHTMLText Field()
- public ArrayList getOptions()
- public $this setConfig()
- public mixed getConfig()
- public $this setMultiple()
- public boolean getMultiple()
- public string getMultipleName()
- public boolean isMultiple()
- public boolean usesTags()
- public array getAttributes()
- public array getDataAttributes()
- public $this setValue()
- public boolean isSelectedValue()
- public array getValueArray()
- public void loadFrom()
- public void saveInto()
- public void loadFromRelation()
- public void saveIntoRelation()
- public boolean validate()
- public string stringEncode()
- public array stringDecode()
- protected string getDataValue()
- protected array getFieldConfig()
- protected Relation getNamedRelation()
Hierarchy
Members
private
- $allowed_actions
—
array
Defines the allowed actions for this field. - $default_ajax_config
—
array
An array which defines the default Ajax configuration for instances. - $default_config
—
array
An array which defines the default configuration for instances.
protected
- $ajaxConfig
—
array
An array which holds the Ajax configuration for an instance. - $ajaxEnabled
—
boolean
Defines whether Ajax is enabled or disabled for the field. - $config
—
array
An array which holds the configuration for an instance. - $dataClass
—
string
The data class to search via Ajax. - $exclude
—
array
An array of filters which specify records to be excluded from the search. - $formatResult
—
string
Defines the string format to use for a result. - $formatSelection
—
string
Defines the string format to use for a selection. - $idField
—
string
The ID field for the data class. - $limit
—
integer
The maximum number of records to answer. - $multiple
—
boolean
Defines whether the field can handle multiple options. - $searchFields
—
array
The fields to search on the data class. - $sortBy
—
SilverWare\Select2\Forms\array|string
The fields to sort the result list by. - $textField
—
string
The text field to display for the data class.
Methods
protected
- getFieldAjaxConfig() — Answers the field Ajax config for the receiver.
- getFieldConfig() — Answers the field config for the receiver.
- getFormattedResult() — Answers a formatted result string for the given record object.
- getFormattedSelection() — Answers a formatted selection string for the given record object.
- getList() — Answers the underlying list for the field.
- getListMap() — Converts the given data source into an array.
- getResultData() — Answers a result data array for the given record object.
- getValueRecord() — Answers the record identified by the given value.
- respond() — Answers an HTTP response object with the given array of JSON data.
public
- __construct() — Constructs the object upon instantiation.
- Type() — Answers the field type for the template.
- getAjaxConfig() — Answers either the named Ajax config value, or the Ajax config array.
- getAjaxEnabled() — Answers the value of the ajaxEnabled attribute.
- getDataAttributes() — Answers an array of data attributes for the field.
- getDataClass() — Answers the value of the dataClass attribute.
- getExclude() — Answers the value of the exclude attribute.
- getFormatResult() — Answers the value of the formatResult attribute.
- getFormatSelection() — Answers the value of the formatSelection attribute.
- getIDField() — Answers the value of the idField attribute.
- getLimit() — Answers the value of the limit attribute.
- getSearchFields() — Answers the value of the searchFields attribute.
- getSearchFilterName() — Answers the name of the search filter for the specified field.
- getSearchFilters() — Answers an array of search filters for the given term.
- getSortBy() — Answers the value of the sortBy attribute.
- getSourceEmpty() — Answers the source array for the field options, including the empty string, if present.
- getTextField() — Answers the value of the textField attribute.
- isAjaxEnabled() — Answers true if Ajax is enabled for the field.
- isSelectedValue() — Answers true if the given data value and user value match (i.e. the value is selected).
- loadFromRelation() — Loads the value of the field from the given relation.
- saveIntoRelation() — Saves the value of the field into the given relation.
- search() — Answers an HTTP response containing JSON results matching the given search parameters.
- setAjaxConfig() — Defines either the named Ajax config value, or the Ajax config array.
- setAjaxEnabled() — Defines the value of the ajaxEnabled attribute.
- setDataClass() — Defines the value of the dataClass attribute.
- setDescriptor() — Updates the text field, search fields and sort order to the specified field name.
- setExclude() — Defines the value of the exclude attribute.
- setFormatResult() — Defines the value of the formatResult attribute.
- setFormatSelection() — Defines the value of the formatSelection attribute.
- setIDField() — Defines the value of the idField attribute.
- setLimit() — Defines the value of the limit attribute.
- setSearchFields() — Defines the value of the searchFields attribute.
- setSortBy() — Defines the value of the sortBy attribute.
- setSource() — Defines the source for the receiver.
- setTextField() — Defines the value of the textField attribute.
Inherited from SilverWare\Select2\Forms\Select2Field
protected
- getDataValue() — Converts the given data value to a string suitable for a data attribute.
- getFieldConfig() — Answers the field config for the receiver.
- getNamedRelation() — Answers the relation with the field name from the given data object.
public
- Field() — Renders the field for the template.
- Type() — Answers the field type for the template.
- getAttributes() — Answers an array of HTML attributes for the field.
- getConfig() — Answers either the named config value, or the config array.
- getDataAttributes() — Answers an array of data attributes for the field.
- getMultiple() — Answers the value of the multiple attribute.
- getMultipleName() — Answers the multiple name of the field.
- getOptions() — Answers an array list containing the options for the field.
- getValueArray() — Answers the value(s) of this field as an array.
- isMultiple() — Answers true if the field handles multiple tags.
- isSelectedValue() — Answers true if the current value of this field matches the given option value.
- loadFrom() — Loads the value of the field from the given data object.
- loadFromRelation() — Loads the value of the field from the given relation.
- saveInto() — Saves the value of the field into the given data object.
- saveIntoRelation() — Saves the value of the field into the given relation.
- setConfig() — Defines either the named config value, or the config array.
- setMultiple() — Defines the value of the multiple attribute.
- setValue() — Defines the value of the field.
- stringDecode() — Decodes the given string of values into an array.
- stringEncode() — Converts the given array of values into a string.
- usesTags() — Answers true if the field is configured to use tags.
- validate() — Performs validation on the receiver.