protected function prepareView(FormView $view, FormInterface $form, array $options)
    {
        if (isset($options['choice_loader'])
            && $options['choice_loader'] instanceof DynamicChoiceLoaderInterface) {
            /* @var DynamicChoiceLoaderInterface $loader */
            $loader = $options['choice_loader'];
            $values = $form->getData() instanceof ArrayCollection ? $form->getData()->toArray() : $form->getData();
            $values = \is_object($values) ? [$values] : (array) $values;
            $choiceListView = $this->createChoiceListView($loader->loadChoiceListForView($values, $options['choice_name']), $options);

            $view->vars = array_replace($view->vars, [
                'preferred_choices' => $choiceListView->preferredChoices,
                'choices' => $choiceListView->choices,
            ]);
        }
    }