abstract class ChoiceControl extends BaseControl

Choice control that allows single item selection.

Properties

protected bool[] $disabledChoices
array $items

Methods

__construct(string|Stringable|null $label = null, array|null $items = null)

No description

void
loadHttpData()

No description

setValue(string|int|BackedEnum|null $value)

Sets selected item (by key).

mixed
getValue()

Returns the selected key, or null if no valid item is selected or the selection is disabled.

string|int|null
getRawValue()

Returns the raw submitted key without validation against the available items.

bool
isFilled()

Is any item selected?

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

Sets items from which to choose. When $useKeys is false, values are used as keys too.

array
getItems()

Returns items from which to choose.

mixed
getSelectedItem()

Returns selected value.

setDisabled(bool|array $value = true)

Disables or enables control or items.

checkDefaultValue(bool $value = true)

Enables or disables validation that the set value exists in the items list.

mixed
getItem(string|int $key)

Returns the item label for the given key, or throws an exception if the key does not exist.

Details

at line 30
__construct(string|Stringable|null $label = null, array|null $items = null)

No description

Parameters

string|Stringable|null $label
array|null $items

at line 39
void loadHttpData()

No description

Return Value

void

at line 51
ChoiceControl setValue(string|int|BackedEnum|null $value)

internal  
 

Sets selected item (by key).

Parameters

string|int|BackedEnum|null $value

Return Value

ChoiceControl

at line 71
mixed getValue()

Returns the selected key, or null if no valid item is selected or the selection is disabled.

Return Value

mixed

at line 84
string|int|null getRawValue()

Returns the raw submitted key without validation against the available items.

Return Value

string|int|null

at line 93
bool isFilled()

Is any item selected?

Return Value

bool

at line 103
ChoiceControl setItems(array $items, bool $useKeys = true)

Sets items from which to choose. When $useKeys is false, values are used as keys too.

Parameters

array $items
bool $useKeys

Return Value

ChoiceControl

at line 114
array getItems()

Returns items from which to choose.

Return Value

array

at line 123
mixed getSelectedItem()

Returns selected value.

Return Value

mixed

at line 134
ChoiceControl setDisabled(bool|array $value = true)

Disables or enables control or items.

Parameters

bool|array $value

Return Value

ChoiceControl

at line 148
ChoiceControl checkDefaultValue(bool $value = true)

Enables or disables validation that the set value exists in the items list.

Parameters

bool $value

Return Value

ChoiceControl

at line 158
protected mixed getItem(string|int $key)

Returns the item label for the given key, or throws an exception if the key does not exist.

Parameters

string|int $key

Return Value

mixed