|
@@ -28,14 +28,9 @@ class TimeType extends AbstractType
|
|
|
*/
|
|
|
public function buildForm(FormBuilder $builder, array $options)
|
|
|
{
|
|
|
- $parts = array('hour', 'minute');
|
|
|
- if ($options['with_seconds']) {
|
|
|
- $parts[] = 'second';
|
|
|
- }
|
|
|
-
|
|
|
if ($options['widget'] === 'single_text') {
|
|
|
$builder->appendClientTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['user_timezone'], 'H:i:s'));
|
|
|
- } else {
|
|
|
+ } else if ($options['widget'] === 'choice') {
|
|
|
if (is_array($options['empty_value'])) {
|
|
|
$options['empty_value'] = array_merge(array('hour' => null, 'minute' => null, 'second' => null), $options['empty_value']);
|
|
|
} else {
|
|
@@ -68,13 +63,11 @@ class TimeType extends AbstractType
|
|
|
'required' => $options['required'],
|
|
|
));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- $builder->appendClientTransformer(new DateTimeToArrayTransformer(
|
|
|
- $options['data_timezone'],
|
|
|
- $options['user_timezone'],
|
|
|
- $parts,
|
|
|
- $options['widget'] === 'text'
|
|
|
- ));
|
|
|
+ $parts = array('hour', 'minute');
|
|
|
+ if ($options['with_seconds']) {
|
|
|
+ $parts[] = 'second';
|
|
|
}
|
|
|
|
|
|
if ($options['input'] === 'string') {
|
|
@@ -91,6 +84,15 @@ class TimeType extends AbstractType
|
|
|
));
|
|
|
}
|
|
|
|
|
|
+ if ($options['widget'] !== 'single_text') {
|
|
|
+ $builder->appendClientTransformer(new DateTimeToArrayTransformer(
|
|
|
+ $options['data_timezone'],
|
|
|
+ $options['user_timezone'],
|
|
|
+ $parts,
|
|
|
+ $options['widget'] === 'text'
|
|
|
+ ));
|
|
|
+ }
|
|
|
+
|
|
|
$builder
|
|
|
->setAttribute('widget', $options['widget'])
|
|
|
->setAttribute('with_seconds', $options['with_seconds'])
|