From b6831d2ab2caf31510197aa12d6e4e7ee208358d Mon Sep 17 00:00:00 2001 From: Maxime Steinhausser Date: Mon, 12 Dec 2016 23:36:40 +0100 Subject: [PATCH] [Form] DateIntervalType: Do not try to translate choices --- .../Extension/Core/Type/DateIntervalType.php | 1 + .../Core/Type/DateIntervalTypeTest.php | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php b/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php index fb2b7d7ff3ec..4e3f6726c5db 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php @@ -102,6 +102,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $childOptions[$part] = array(); $childOptions[$part]['error_bubbling'] = true; if ('choice' === $options['widget']) { + $childOptions[$part]['choice_translation_domain'] = false; $childOptions[$part]['choices'] = $options[$part]; $childOptions[$part]['placeholder'] = $options['placeholder'][$part]; } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php index e40c0949f696..62e6d34c8517 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php @@ -11,6 +11,7 @@ namespace Symfony\Component\Form\Tests\Extension\Core\Type; +use Symfony\Component\Form\Extension\Core\Type\DateIntervalType; use Symfony\Component\Form\FormError; use Symfony\Component\Form\Test\TypeTestCase as TestCase; @@ -364,4 +365,23 @@ public function testDateTypeChoiceErrorsBubbleUp() $this->assertSame(array(), iterator_to_array($form['years']->getErrors())); $this->assertSame(array($error), iterator_to_array($form->getErrors())); } + public function testTranslationsAreDisabledForChoiceWidget() + { + $form = $this->factory->create( + DateIntervalType::class, + null, + array( + 'widget' => 'choice', + 'with_hours' => true, + 'with_minutes' => true, + 'with_seconds' => true, + ) + ); + $this->assertFalse($form->get('years')->getConfig()->getOption('choice_translation_domain')); + $this->assertFalse($form->get('months')->getConfig()->getOption('choice_translation_domain')); + $this->assertFalse($form->get('days')->getConfig()->getOption('choice_translation_domain')); + $this->assertFalse($form->get('hours')->getConfig()->getOption('choice_translation_domain')); + $this->assertFalse($form->get('minutes')->getConfig()->getOption('choice_translation_domain')); + $this->assertFalse($form->get('seconds')->getConfig()->getOption('choice_translation_domain')); + } }