Skip to content

Commit b6831d2

Browse files
committed
[Form] DateIntervalType: Do not try to translate choices
1 parent fef1546 commit b6831d2

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/Symfony/Component/Form/Extension/Core/Type/DateIntervalType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
102102
$childOptions[$part] = array();
103103
$childOptions[$part]['error_bubbling'] = true;
104104
if ('choice' === $options['widget']) {
105+
$childOptions[$part]['choice_translation_domain'] = false;
105106
$childOptions[$part]['choices'] = $options[$part];
106107
$childOptions[$part]['placeholder'] = $options['placeholder'][$part];
107108
}

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateIntervalTypeTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Component\Form\Extension\Core\Type\DateIntervalType;
1415
use Symfony\Component\Form\FormError;
1516
use Symfony\Component\Form\Test\TypeTestCase as TestCase;
1617

@@ -364,4 +365,23 @@ public function testDateTypeChoiceErrorsBubbleUp()
364365
$this->assertSame(array(), iterator_to_array($form['years']->getErrors()));
365366
$this->assertSame(array($error), iterator_to_array($form->getErrors()));
366367
}
368+
public function testTranslationsAreDisabledForChoiceWidget()
369+
{
370+
$form = $this->factory->create(
371+
DateIntervalType::class,
372+
null,
373+
array(
374+
'widget' => 'choice',
375+
'with_hours' => true,
376+
'with_minutes' => true,
377+
'with_seconds' => true,
378+
)
379+
);
380+
$this->assertFalse($form->get('years')->getConfig()->getOption('choice_translation_domain'));
381+
$this->assertFalse($form->get('months')->getConfig()->getOption('choice_translation_domain'));
382+
$this->assertFalse($form->get('days')->getConfig()->getOption('choice_translation_domain'));
383+
$this->assertFalse($form->get('hours')->getConfig()->getOption('choice_translation_domain'));
384+
$this->assertFalse($form->get('minutes')->getConfig()->getOption('choice_translation_domain'));
385+
$this->assertFalse($form->get('seconds')->getConfig()->getOption('choice_translation_domain'));
386+
}
367387
}

0 commit comments

Comments
 (0)