8000 [Form] Fixed empty data for compound date interval · symfony/symfony@0a0eb62 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0a0eb62

Browse files
committed
[Form] Fixed empty data for compound date interval
1 parent 0c44633 commit 0a0eb62

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
104104
// Append generic carry-along options
105105
'required' => $options['required'],
106106
'translation_domain' => $options['translation_domain'],
107+
// when compound the array entries are ignored, we need to cascade the configuration here
108+
'empty_data' => isset($options['empty_data'][$part]) ? $options['empty_data'][$part] : null,
107109
);
108110
if ('choice' === $options['widget']) {
109111
$childOptions['choice_translation_domain'] = false;

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,10 +446,9 @@ public function provideEmptyData()
446446

447447
return array(
448448
'Simple field' => array('single_text', 'P6Y4M0D', $expectedData),
449-
// Compound tests are broken for now
450-
//'Compound text field' => array('text', array('years' => '06', 'months' => '04', 'days' => '00'), $expectedData),
451-
//'Compound integer field' => array('integer', array('years' => '6', 'months' => '4', 'days' => '0'), $expectedData),
452-
//'Compound choice field' => array('choice', array('years' => '6', 'months' => '4', 'days' => '0'), $expectedData),
449+
'Compound text field' => array('text', array('years' => '06', 'months' => '04', 'days' => '00'), $expectedData),
450+
'Compound integer field' => array('integer', array('years' => '6', 'months' => '4', 'days' => '0'), $expectedData),
451+
'Compound choice field' => array('choice', array('years' => '6', 'months' => '4', 'days' => '0'), $expectedData),
453452
);
454453
}
455454
}

0 commit comments

Comments
 (0)
0