ChoiceToBooleanArrayTransformer deprecated
class ChoiceToBooleanArrayTransformer implements DataTransformerInterface
deprecated
Methods
__construct(ChoiceListInterface $choiceList, bool $placeholderPresent) Constructor. | ||
mixed | transform(mixed $choice) Transforms a single choice to a format appropriate for the nested checkboxes/radio buttons. | |
mixed | reverseTransform(array $values) Transforms a checkbox/radio button array to a single choice. |
Details
__construct(ChoiceListInterface $choiceList, bool $placeholderPresent)
Constructor.
Parameters
ChoiceListInterface | $choiceList | |
bool | $placeholderPresent |
mixed transform(mixed $choice)
Transforms a single choice to a format appropriate for the nested checkboxes/radio buttons.
The result is an array with the options as keys and true/false as values, depending on whether a given option is selected. If this field is rendered as select tag, the value is not modified.
Parameters
mixed | $choice | An array if "multiple" is set to true, a scalar value otherwise. |
Return Value
mixed | The value in the transformed representation |
Exceptions
TransformationFailedException | If the given value is not scalar or if the choices can not be retrieved. |
mixed reverseTransform(array $values)
Transforms a checkbox/radio button array to a single choice.
The input value is an array with the choices as keys and true/false as values, depending on whether a given choice is selected. The output is the selected choice.
Parameters
array | $values | An array of values |
Return Value
mixed | The value in the original representation |
Exceptions
TransformationFailedException | If the given value is not an array, if the recuperation of the choices fails or if some choice can't be found. |
© 2004–2017 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.html