|
@@ -14,6 +14,7 @@ namespace Symfony\Component\Form\Extension\Core\Type;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\FormInterface;
|
|
use Symfony\Component\Form\FormInterface;
|
|
use Symfony\Component\Form\FormBuilder;
|
|
use Symfony\Component\Form\FormBuilder;
|
|
|
|
+use Symfony\Component\Form\Exception\FormException;
|
|
use Symfony\Component\Form\Extension\Core\ChoiceList\PaddedChoiceList;
|
|
use Symfony\Component\Form\Extension\Core\ChoiceList\PaddedChoiceList;
|
|
use Symfony\Component\Form\Extension\Core\ChoiceList\MonthChoiceList;
|
|
use Symfony\Component\Form\Extension\Core\ChoiceList\MonthChoiceList;
|
|
use Symfony\Component\Form\FormView;
|
|
use Symfony\Component\Form\FormView;
|
|
@@ -36,7 +37,7 @@ class DateType extends AbstractType
|
|
|
|
|
|
if ($options['widget'] === 'text') {
|
|
if ($options['widget'] === 'text') {
|
|
$builder->appendClientTransformer(new DateTimeToLocalizedStringTransformer($options['data_timezone'], $options['user_timezone'], $options['format'], \IntlDateFormatter::NONE));
|
|
$builder->appendClientTransformer(new DateTimeToLocalizedStringTransformer($options['data_timezone'], $options['user_timezone'], $options['format'], \IntlDateFormatter::NONE));
|
|
- } else {
|
|
|
|
|
|
+ } elseif ($options['widget'] == 'choice') {
|
|
// Only pass a subset of the options to children
|
|
// Only pass a subset of the options to children
|
|
$yearOptions = array(
|
|
$yearOptions = array(
|
|
'choice_list' => new PaddedChoiceList(
|
|
'choice_list' => new PaddedChoiceList(
|
|
@@ -58,6 +59,8 @@ class DateType extends AbstractType
|
|
->add('month', 'choice', $monthOptions)
|
|
->add('month', 'choice', $monthOptions)
|
|
->add('day', 'choice', $dayOptions)
|
|
->add('day', 'choice', $dayOptions)
|
|
->appendClientTransformer(new DateTimeToArrayTransformer($options['data_timezone'], $options['user_timezone'], array('year', 'month', 'day')));
|
|
->appendClientTransformer(new DateTimeToArrayTransformer($options['data_timezone'], $options['user_timezone'], array('year', 'month', 'day')));
|
|
|
|
+ } else {
|
|
|
|
+ throw new FormException('The "widget" option must be set to either "text" or "choice".');
|
|
}
|
|
}
|
|
|
|
|
|
if ($options['input'] === 'string') {
|
|
if ($options['input'] === 'string') {
|
|
@@ -72,6 +75,8 @@ class DateType extends AbstractType
|
|
$builder->appendNormTransformer(new ReversedTransformer(
|
|
$builder->appendNormTransformer(new ReversedTransformer(
|
|
new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], array('year', 'month', 'day'))
|
|
new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], array('year', 'month', 'day'))
|
|
));
|
|
));
|
|
|
|
+ } else if ($options['input'] !== 'datetime') {
|
|
|
|
+ throw new FormException('The "input" option must be "datetime", "string", "timestamp" or "array".');
|
|
}
|
|
}
|
|
|
|
|
|
$builder
|
|
$builder
|