Documentation

ChoiceFormField extends FormField
in package

ChoiceFormField represents a choice form field.

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

Tags
author

Fabien Potencier fabien@symfony.com

Table of Contents

$disabled  : bool
$document  : DOMDocument
$name  : string
$node  : DOMElement
$value  : string
$xpath  : DOMXPath
$multiple  : bool
$options  : array<string|int, mixed>
$type  : string
$validationDisabled  : bool
__construct()  : mixed
availableOptionValues()  : array<string|int, mixed>
Returns list of available field options.
containsOption()  : bool
Checks whether given value is in the existing options.
disableValidation()  : self
Disables the internal validation of the field.
getLabel()  : DOMElement|null
Returns the label tag associated to the field or null if none.
getName()  : string
Returns the name of the field.
getType()  : string
Returns the type of the choice field (radio, select, or checkbox).
getValue()  : string|array<string|int, mixed>
Gets the value of the field.
hasValue()  : bool
Returns true if the field should be included in the submitted values.
isDisabled()  : bool
Check if the current selected option is disabled.
isMultiple()  : bool
Returns true if the field accepts multiple values.
select()  : mixed
Sets the value of the field.
setValue()  : mixed
Sets the value of the field.
tick()  : mixed
Ticks a checkbox.
untick()  : mixed
Unticks a checkbox.
initialize()  : mixed
Initializes the form field.
buildOptionValue()  : array<string|int, mixed>
Returns option value with associated disabled flag.

Properties

Methods

__construct()

public __construct(DOMElement $node) : mixed
Parameters
$node : DOMElement

The node associated with this field

Return values
mixed

availableOptionValues()

Returns list of available field options.

public availableOptionValues() : array<string|int, mixed>
Return values
array<string|int, mixed>

containsOption()

Checks whether given value is in the existing options.

public containsOption(string $optionValue, array<string|int, mixed> $options) : bool
Parameters
$optionValue : string
$options : array<string|int, mixed>
Return values
bool

disableValidation()

Disables the internal validation of the field.

public disableValidation() : self
Return values
self

getLabel()

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

public getLabel() : DOMElement|null
Return values
DOMElement|null

getName()

Returns the name of the field.

public getName() : string
Return values
string

The name of the field

getType()

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

public getType() : string
Return values
string

The type

getValue()

Gets the value of the field.

public getValue() : string|array<string|int, mixed>
Return values
string|array<string|int, mixed>

The value of the field

hasValue()

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

public hasValue() : bool
Return values
bool

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

isDisabled()

Check if the current selected option is disabled.

public isDisabled() : bool
Return values
bool

isMultiple()

Returns true if the field accepts multiple values.

public isMultiple() : bool
Return values
bool

true if the field accepts multiple values, false otherwise

select()

Sets the value of the field.

public select(string|array<string|int, mixed> $value) : mixed
Parameters
$value : string|array<string|int, mixed>

The value of the field

Return values
mixed

setValue()

Sets the value of the field.

public setValue(string|array<string|int, mixed>|bool|null $value) : mixed
Parameters
$value : string|array<string|int, mixed>|bool|null

The value of the field

Tags
throws
InvalidArgumentException

When value type provided is not correct

Return values
mixed

tick()

Ticks a checkbox.

public tick() : mixed
Tags
throws
LogicException

When the type provided is not correct

Return values
mixed

untick()

Unticks a checkbox.

public untick() : mixed
Tags
throws
LogicException

When the type provided is not correct

Return values
mixed

initialize()

Initializes the form field.

protected initialize() : mixed
Tags
throws
LogicException

When node type is incorrect

Return values
mixed

buildOptionValue()

Returns option value with associated disabled flag.

private buildOptionValue(DOMElement $node) : array<string|int, mixed>
Parameters
$node : DOMElement
Return values
array<string|int, mixed>

Search results