diff --git a/Form/Extension/ChoiceTypeExtension.php b/Form/Extension/ChoiceTypeExtension.php index ede1067f75..87e3ca2f39 100644 --- a/Form/Extension/ChoiceTypeExtension.php +++ b/Form/Extension/ChoiceTypeExtension.php @@ -56,12 +56,16 @@ public function buildView(FormView $view, FormInterface $form, array $options) } /** - * Returns the name of the type being extended. - * - * @return string The name of the type being extended + * {@inheritdoc} */ public function getExtendedType() { - return 'choice'; + /* + * NEXT_MAJOR: Remove when dropping Symfony <2.8 support. It should + * simply be return 'Symfony\Component\Form\Extension\Core\Type\ChoiceType'; + */ + return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') + ? 'Symfony\Component\Form\Extension\Core\Type\ChoiceType' + : 'choice'; } } diff --git a/Form/Extension/Field/Type/MopaCompatibilityTypeFieldExtension.php b/Form/Extension/Field/Type/MopaCompatibilityTypeFieldExtension.php index f4b038191f..24ea27f9fe 100644 --- a/Form/Extension/Field/Type/MopaCompatibilityTypeFieldExtension.php +++ b/Form/Extension/Field/Type/MopaCompatibilityTypeFieldExtension.php @@ -58,12 +58,16 @@ public function buildView(FormView $view, FormInterface $form, array $options) } /** - * Returns the name of the type being extended. - * - * @return string The name of the type being extended + * {@inheritdoc} */ public function getExtendedType() { - return 'form'; + /* + * NEXT_MAJOR: Remove when dropping Symfony <2.8 support. It should + * simply be return 'Symfony\Component\Form\Extension\Core\Type\FormType'; + */ + return method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix') + ? 'Symfony\Component\Form\Extension\Core\Type\FormType' + : 'form'; } } diff --git a/Tests/Form/Extension/ChoiceTypeExtensionTest.php b/Tests/Form/Extension/ChoiceTypeExtensionTest.php index 7fc4d07f4c..270cf42eea 100644 --- a/Tests/Form/Extension/ChoiceTypeExtensionTest.php +++ b/Tests/Form/Extension/ChoiceTypeExtensionTest.php @@ -62,7 +62,23 @@ public function testExtendedType() { $extension = new ChoiceTypeExtension(); - $this->assertSame('choice', $extension->getExtendedType()); + /* + * NEXT_MAJOR: Remove when dropping Symfony <2.8 support. It should + * simply be: + * + * $this->assertSame( + * 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', + * $extension->getExtendedType() + * ); + */ + if (method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix')) { + $this->assertSame( + 'Symfony\Component\Form\Extension\Core\Type\ChoiceType', + $extension->getExtendedType() + ); + } else { + $this->assertSame('choice', $extension->getExtendedType()); + } } public function testDefaultOptionsWithSortable()