ChoicesToBooleanArrayTransformer deprecated

ChoicesToBooleanArrayTransformer deprecated

class ChoicesToBooleanArrayTransformer implements DataTransformerInterface

deprecated

since version 2.7, to be removed in 3.0. Use {@link \Symfony\Component\Form\ChoiceList\LazyChoiceList} instead.

Methods

__construct(ChoiceListInterface $choiceList)
mixed transform(mixed $array)

Transforms an array of choices to a format appropriate for the nested checkboxes/radio buttons.

mixed reverseTransform(mixed $values)

Transforms a checkbox/radio button array to an array of choices.

Details

__construct(ChoiceListInterface $choiceList)

Parameters

ChoiceListInterface $choiceList

mixed transform(mixed $array)

Transforms an array of choices 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 $array An array

Return Value

mixed The value in the transformed representation

Exceptions

TransformationFailedException If the given value is not an array or if the choices can not be retrieved.

mixed reverseTransform(mixed $values)

Transforms a checkbox/radio button array to an array of choices.

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 an array with the selected choices.

Parameters

mixed $values An array

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.
在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部