abstract class ChoiceControl extends BaseControl

Choice control that allows single item selection.

Properties

array $items
bool|bool[] $disabled
mixed read-only $selectedItem

Methods

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

No description

void
loadHttpData()

Loads HTTP data.

setValue(mixed $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.

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()

Loads HTTP data.

Return Value

void

at line 52
Control setValue(mixed $value)

internal  
 

Sets selected item (by key).

Parameters

mixed $value

Return Value

Control

at line 72
mixed getValue()

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

Return Value

mixed

at line 85
string|int|null getRawValue()

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

Return Value

string|int|null

at line 94
bool isFilled()

Is any item selected?

Return Value

bool

at line 105
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 116
array getItems()

Returns items from which to choose.

Return Value

array

at line 125
mixed getSelectedItem()

Returns selected value.

Return Value

mixed

at line 136
BaseControl setDisabled(bool|array $value = true)

Disables or enables control or items.

Parameters

bool|array $value

Return Value

BaseControl

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

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

Parameters

bool $value

Return Value

ChoiceControl