Form/Extension/ChoiceTypeExtension.php
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addModelTransformer(
            new CallbackTransformer(
                function ($toView) {
                    if ($toView instanceof \Traversable) {
                        return iterator_to_array($toView);
                    }

                    return $toView;
                },
                function ($toModel) {
                    return $toModel;
                }
            )
        );
    }
public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->addModelTransformer(
            new CallbackTransformer(
                function ($toView) {
                    if ($toView instanceof \Traversable) {
                        return iterator_to_array($toView);
                    }

                    return $toView;
                },
                function ($toModel) {
                    return $toModel;
                }
            )
        );
    }
@param FormBuilderInterface $builder
@param array                $options

@throws \InvalidArgumentException