ChoiceFormField

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.

Methods

__construct(DOMElement $node)

Constructor.

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.

select(string $value)

Sets the value of the field.

tick()

Ticks a checkbox.

untick()

Ticks 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.

ChoiceFormField disableValidation()

Disables the internal validation of the field.

Details

__construct(DOMElement $node)

Constructor.

Parameters

DOMElement $node The node associated with this field

string getName()

Returns the name of the field.

Return Value

string The name of the field

string|array getValue()

Gets the value of the field.

Return Value

string|array The value of the field

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

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

bool isDisabled()

Check if the current selected option is disabled.

Return Value

bool

select(string $value)

Sets the value of the field.

Parameters

string $value The value of the field

tick()

Ticks a checkbox.

Exceptions

LogicException When the type provided is not correct

untick()

Ticks a checkbox.

Exceptions

LogicException When the type provided is not correct

addChoice(DOMElement $node)

Adds a choice to the current ones.

This method should only be used internally.

Parameters

DOMElement $node

Exceptions

LogicException When choice provided is not multiple nor radio

string getType()

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

Return Value

string The type

bool isMultiple()

Returns true if the field accepts multiple values.

Return Value

bool true if the field accepts multiple values, false otherwise

bool containsOption(string $optionValue, array $options)

Checks whether given value is in the existing options.

Parameters

string $optionValue
array $options

Return Value

bool

array availableOptionValues()

Returns list of available field options.

Return Value

array

ChoiceFormField disableValidation()

Disables the internal validation of the field.

Return Value

ChoiceFormField
doc_Symfony
2016-10-28 06:08:33
Comments
Leave a Comment

Please login to continue.