Form/Extension/ChoiceTypeParentExtension.php
public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $fieldDefined = 0 < strlen($options['parent_choice_field']);
        $routeDefined = 0 < strlen($options['parent_choice_route']);

        if (($fieldDefined && !$routeDefined) || (!$fieldDefined && $routeDefined)) {
            throw new MissingOptionsException(self::BOTH_OR_NONE);
        }

        if ($fieldDefined && $routeDefined) {
            $view->vars['attr']['data-parent-choice'] = json_encode([
                'field' => $view->parent->vars['id'].'_'.$options['parent_choice_field'],
                'route' => $options['parent_choice_route'],
            ]);
        }
    }
public function buildView(FormView $view, FormInterface $form, array $options)
    {
        $fieldDefined = 0 < strlen($options['parent_choice_field']);
        $routeDefined = 0 < strlen($options['parent_choice_route']);

        if (($fieldDefined && !$routeDefined) || (!$fieldDefined && $routeDefined)) {
            throw new MissingOptionsException(self::BOTH_OR_NONE);
        }

        if ($fieldDefined && $routeDefined) {
            $view->vars['attr']['data-parent-choice'] = json_encode([
                'field' => $view->parent->vars['id'].'_'.$options['parent_choice_field'],
                'route' => $options['parent_choice_route'],
            ]);
        }
    }
{@inheritDoc}