class ChoiceFormField extends FormField

ChoiceFormField represents a choice form field.

It is constructed from a HTML select tag, or a HTML checkbox, or radio inputs.

Properties

protected DOMElement $node from FormField
protected string $name from FormField
protected string $value from FormField
protected DOMDocument $document from FormField
protected DOMXPath $xpath from FormField
protected bool $disabled from FormField

Methods

__construct(DOMElement $node)

No description

from FormField
DOMElement|null
getLabel()

Returns the label tag associated to the field or null if none.

from FormField
string
getName()

Returns the name of the field.

from FormField
string|array
getValue()

Gets the value of the field.

from FormField
setValue(string $value)

Sets the value of the field.

bool
hasValue()

Returns true if the field should be included in the submitted values.

bool
isDisabled()

Check if the current selected option is disabled.

initialize()

Initializes the form field.

select(string|array $value)

Sets the value of the field.

tick()

Ticks a checkbox.

untick()

Unticks a checkbox.

addChoice(DOMElement $node)

Adds a choice to the current ones.

string
getType()

Returns the type of the choice field (radio, select, or checkbox).

bool
isMultiple()

Returns true if the field accepts multiple values.

bool
containsOption(string $optionValue, array $options)

Checks whether given value is in the existing options.

array
availableOptionValues()

Returns list of available field options.

disableValidation()

Disables the internal validation of the field.

Details

in FormField at line 49
__construct(DOMElement $node)

Parameters

DOMElement $node The node associated with this field

in FormField at line 63
DOMElement|null getLabel()

Returns the label tag associated to the field or null if none.

Return Value

DOMElement|null

in FormField at line 85
string getName()

Returns the name of the field.

Return Value

string The name of the field

in FormField at line 95
string|array getValue()

Gets the value of the field.

Return Value

string|array The value of the field

at line 120
setValue(string $value)

Sets the value of the field.

Parameters

string $value The value of the field

Exceptions

InvalidArgumentException When value type provided is not correct

at line 45
bool hasValue()

Returns true if the field should be included in the submitted values.

Return Value

bool true if the field should be included in the submitted values, false otherwise

at line 60
bool isDisabled()

Check if the current selected option is disabled.

Return Value

bool

at line 203
protected initialize()

Initializes the form field.

Exceptions

LogicException When node type is incorrect

at line 80
select(string|array $value)

Sets the value of the field.

Parameters

string|array $value The value of the field

at line 90
tick()

Ticks a checkbox.

Exceptions

LogicException When the type provided is not correct

at line 104
untick()

Unticks a checkbox.

Exceptions

LogicException When the type provided is not correct

at line 164
addChoice(DOMElement $node)

Adds a choice to the current ones.

Parameters

DOMElement $node

Exceptions

LogicException When choice provided is not multiple nor radio

at line 183
string getType()

Returns the type of the choice field (radio, select, or checkbox).

Return Value

string The type

at line 193
bool isMultiple()

Returns true if the field accepts multiple values.

Return Value

bool true if the field accepts multiple values, false otherwise

at line 282
bool containsOption(string $optionValue, array $options)

Checks whether given value is in the existing options.

Parameters

string $optionValue
array $options

Return Value

bool

at line 302
array availableOptionValues()

Returns list of available field options.

Return Value

array

at line 318
ChoiceFormField disableValidation()

Disables the internal validation of the field.

Return Value

ChoiceFormField