[Form] Fixed TimeType not to render a "size" attribute in select tags

This commit is contained in:
Bernhard Schussek 2013-02-22 13:48:44 +01:00
parent 0fb397ccfb
commit b7bd630652
3 changed files with 12 additions and 9 deletions

View File

@ -147,8 +147,9 @@
{% if widget == 'single_text' %}
{{ block('form_widget_simple') }}
{% else %}
{% set vars = widget == 'text' ? { 'attr': { 'size': 1 }} : {} %}
<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, vars) }}:{{ form_widget(form.minute, vars) }}{% if with_seconds %}:{{ form_widget(form.second, vars) }}{% endif %}
</div>
{% endif %}
{% endspaceless %}

View File

@ -1,17 +1,18 @@
<?php if ($widget == 'single_text'): ?>
<?php echo $view['form']->block($form, 'form_widget_simple'); ?>
<?php else: ?>
<?php $vars = $widget == 'text' ? array('attr' => array('size' => 1)) : array() ?>
<div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>>
<?php
// There should be no spaces between the colons and the widgets, that's why
// this block is written in a single PHP tag
echo $view['form']->widget($form['hour'], array('attr' => array('size' => 1)));
echo $view['form']->widget($form['hour'], $vars);
echo ':';
echo $view['form']->widget($form['minute'], array('attr' => array('size' => 1)));
echo $view['form']->widget($form['minute'], $vars);
if ($with_seconds) {
echo ':';
echo $view['form']->widget($form['second'], array('attr' => array('size' => 1)));
echo $view['form']->widget($form['second'], $vars);
}
?>
</div>

View File

@ -1531,11 +1531,11 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[
./select
[@id="name_hour"]
[@size="1"]
[not(@size)]
[./option[@value="4"][@selected="selected"]]
/following-sibling::select
[@id="name_minute"]
[@size="1"]
[not(@size)]
[./option[@value="5"][@selected="selected"]]
]
[count(./select)=2]
@ -1555,17 +1555,17 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[
./select
[@id="name_hour"]
[@size="1"]
[not(@size)]
[./option[@value="4"][@selected="selected"]]
[count(./option)>23]
/following-sibling::select
[@id="name_minute"]
[@size="1"]
[not(@size)]
[./option[@value="5"][@selected="selected"]]
[count(./option)>59]
/following-sibling::select
[@id="name_second"]
[@size="1"]
[not(@size)]
[./option[@value="6"][@selected="selected"]]
[count(./option)>59]
]
@ -1616,6 +1616,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
[@type="time"]
[@name="name"]
[@value="04:05"]
[not(@size)]
'
);
}