[Form] DateIntervalType: Do not try to translate choices
This commit is contained in:
parent
fef1546a7e
commit
b6831d2ab2
@ -102,6 +102,7 @@ class DateIntervalType extends AbstractType
|
||||
$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];
|
||||
}
|
||||
|
@ -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 @@ class DateIntervalTypeTest extends TestCase
|
||||
$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'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user