trait ChoiceInputTrait

Trait ChoiceInputTrait.

Provides basic functionality for inputs where one of more than one predefined values are possible.

Properties

protected array $rawItems

Methods

array
flatAssocArray(array $array)

Processes an associative array in a way that it has no nesting. Keys for nested arrays are lost, but nested arrays are merged.

array
makeOptionList(array $items, callable $optionArgs, array $valuesRendered = [])

Makes array of <option>. Can handle associative arrays just fine. Checks for duplicate values.

setItems(array $items, bool $useKeys = TRUE)

No description

bool
isControlDisabled()

Check if whole control is disabled.

bool
isValueDisabled($value)

Check if a specific value is disabled. If whole control is disabled, returns false.

bool
isValueSelected($value)

Self-explanatory

Details

at line 35
array flatAssocArray(array $array)

Processes an associative array in a way that it has no nesting. Keys for nested arrays are lost, but nested arrays are merged.

Parameters

array $array

Return Value

array

at line 59
array makeOptionList(array $items, callable $optionArgs, array $valuesRendered = [])

Makes array of <option>. Can handle associative arrays just fine. Checks for duplicate values.

Parameters

array $items
callable $optionArgs takes ($value,$caption) and spits out an array of <option> attributes
array $valuesRendered for internal use. Do not change.

Return Value

array

Exceptions

InvalidArgumentException when $items have multiple of the same values

at line 100
ChoiceInputTrait setItems(array $items, bool $useKeys = TRUE)

Parameters

array $items Items to set. Associative arrays are supported.
bool $useKeys

Return Value

ChoiceInputTrait

at line 117
protected bool isControlDisabled()

Check if whole control is disabled.

This is false if only a set of values is disabled

Return Value

bool

at line 131
protected bool isValueDisabled($value)

Check if a specific value is disabled. If whole control is disabled, returns false.

Parameters

$value mixed value to check for

Return Value

bool

at line 149
protected bool isValueSelected($value)

Self-explanatory

Parameters

$value

Return Value

bool