InputfieldSelect class

Base for selection form inputs, which by default behaves as a regular <select>

Serves as the base for Inputfields that provide selection of options (whether single or multi). As a result, this class includes functionality for, and checks for both single-and-multi selection values. Sublcasses will want to override the render method, but it's not necessary to override processInput(). Subclasses that select multiple values should implement the InputfieldHasArrayValue interface.


Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the InputfieldSelect class also inherits all the methods and properties of: Inputfield, WireData and Wire.

Show class?     Show args?       Only hookable?    

Common

NameReturnSummary 
InputfieldSelect::addOption(string $value)
$this

Add an option that may be selected

 
InputfieldSelect::addOptionAttributes($key)
$this

Add attributes for an item (without removing existing attributes), or for multiple items

 
InputfieldSelect::addOptionLabel($value, string $label)
$this

Add selectable option with label, optionally for specific language

 
InputfieldSelect::addOptions(array $options)
$this

Add multiple options at once

 
InputfieldSelect::addOptionsString(string $value)
$this

Given a multi-line string, convert it to options, one per line

 
InputfieldSelect::get(string $key)
array mixed null

Get property

 
InputfieldSelect::getConfigInputfields()
InputfieldWrapper

Field configuration

InputfieldSelect::getOptionAttributes()
array

Get an attributes array intended for an item (or for all items)

 
InputfieldSelect::getOptionAttributesString($key)
string

Get an attributes string intended for the <option> element

 
InputfieldSelect::getOptions()
array

Get all options for this Select

 
InputfieldSelect::insertOptionsAfter(array $options)
self

Insert new options after an existing option

 
InputfieldSelect::insertOptionsBefore(array $options)
self

Insert new options before an existing option (or prepend options to beginning)

 
InputfieldSelect::isEmpty()
bool

Is the value empty?

 
InputfieldSelect::isOption($value)
bool

Returns whether the provided value is one of the available options

 
InputfieldSelect::isOptionDisabled($value)
bool

Is the given option value disabled?

 
InputfieldSelect::isOptionSelected($value)
bool

Returns whether the provided value is selected

 
InputfieldSelect::optionAttributes()
array

Get or set option attributes


Can also be used as property: InputfieldSelect::optionAttributes
 
InputfieldSelect::optionLabel($key)
string bool

Get or set label for given option value/key (default language)

 
InputfieldSelect::optionLanguageLabel($language)
string array Inputfield

Get or set alternative language label(s)

 
InputfieldSelect::processInput(WireInputData $input)
$this

Process input from the provided array

InputfieldSelect::removeOption($value)
$this

Remove the option with the given value

 
InputfieldSelect::render()
string

Render and return the output for this Select

InputfieldSelect::renderOptions()
string

Render the given options

 
InputfieldSelect::renderReady()
bool

Render ready

 
InputfieldSelect::renderValue()
string

Render non-editable value

InputfieldSelect::replaceOption($oldValue, $newValue)
bool

Replace an option already present with the new value (and optionally new label and attributes)

 
InputfieldSelect::set(string $key, mixed $value)
Inputfield InputfieldSelect

Set property

 
InputfieldSelect::setAttribute($key, $value)
Inputfield InputfieldSelect

Set attribute

 
InputfieldSelect::setOptionAttributes($key)
$this

Set/replace entire attributes array for an item

 
InputfieldSelect::setOptions(array $options)
$this

Set/replace all options

 

Properties

NameReturnSummary 
InputfieldSelect::defaultValue string int 
InputfieldSelect::options array string Get or set options, array of [value => label], or use options string.  
InputfieldSelect::valueAddOption bool If value attr set from API (only) that is not an option, add it as an option? 3.0.171+
DEFAULT: false
 

Additional methods and properties

In addition to the methods and properties above, InputfieldSelect also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.252