Added to TimeType
extension possibility to render form as single_text
(similar to DateType option) (issue #1205)
Adjusted `DateTimeType` to allow usage of this new feature
This commit is contained in:
parent
59f85b4a6e
commit
17b41b2c51
@ -99,7 +99,7 @@
|
|||||||
{% block time_widget %}
|
{% block time_widget %}
|
||||||
{% spaceless %}
|
{% spaceless %}
|
||||||
{% if widget == 'single_text' %}
|
{% if widget == 'single_text' %}
|
||||||
{{ block('field_widget') }}
|
{{ block('text_widget') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<div {{ block('widget_container_attributes') }}>
|
<div {{ block('widget_container_attributes') }}>
|
||||||
{{ form_widget(form.hour, { 'attr': { 'size': '1' } }) }}:{{ form_widget(form.minute, { 'attr': { 'size': '1' } }) }}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1' } }) }}{% endif %}
|
{{ form_widget(form.hour, { 'attr': { 'size': '1' } }) }}:{{ form_widget(form.minute, { 'attr': { 'size': '1' } }) }}{% if with_seconds %}:{{ form_widget(form.second, { 'attr': { 'size': '1' } }) }}{% endif %}
|
||||||
|
@ -31,8 +31,7 @@ class TimeType extends AbstractType
|
|||||||
if ($options['widget'] === 'single_text') {
|
if ($options['widget'] === 'single_text') {
|
||||||
$builder->appendClientTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['user_timezone'], 'H:i:s'));
|
$builder->appendClientTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['user_timezone'], 'H:i:s'));
|
||||||
} else if ($options['widget'] === 'choice') {
|
} else if ($options['widget'] === 'choice') {
|
||||||
if (is_array($options['empty_value'])) {
|
if (is_array($options['empty_value'])) { $options['empty_value'] = array_merge(array('hour' => null, 'minute' => null, 'second' => null), $options['empty_value']);
|
||||||
$options['empty_value'] = array_merge(array('hour' => null, 'minute' => null, 'second' => null), $options['empty_value']);
|
|
||||||
} else {
|
} else {
|
||||||
$options['empty_value'] = array('hour' => $options['empty_value'], 'minute' => $options['empty_value'], 'second' => $options['empty_value']);
|
$options['empty_value'] = array('hour' => $options['empty_value'], 'minute' => $options['empty_value'], 'second' => $options['empty_value']);
|
||||||
}
|
}
|
||||||
@ -66,10 +65,9 @@ class TimeType extends AbstractType
|
|||||||
}
|
}
|
||||||
|
|
||||||
$parts = array('hour', 'minute');
|
$parts = array('hour', 'minute');
|
||||||
if ($options['with_seconds']) {
|
if ($options['with_seconds']) { if ($options['with_seconds']) {
|
||||||
$parts[] = 'second';
|
$parts[] = 'second';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($options['input'] === 'string') {
|
if ($options['input'] === 'string') {
|
||||||
$builder->appendNormTransformer(new ReversedTransformer(
|
$builder->appendNormTransformer(new ReversedTransformer(
|
||||||
new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'H:i:s')
|
new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'H:i:s')
|
||||||
|
Reference in New Issue
Block a user