Parcourir la source

[Form] Added functional test for the 'size' attribute in the select tags of a time field

Bernhard Schussek il y a 14 ans
Parent
commit
c6fe6a750d

+ 3 - 3
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/time_widget.html.php

@@ -2,13 +2,13 @@
     <?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('size' => 1));
+        echo $view['form']->widget($form['hour'], array('attr' => array('size' => 1)));
         echo ':';
-        echo $view['form']->widget($form['minute'], array('size' => 1));
+        echo $view['form']->widget($form['minute'], array('attr' => array('size' => 1)));
 
         if ($with_seconds) {
             echo ':';
-            echo $view['form']->widget($form['second'], array('size' => 1));
+            echo $view['form']->widget($form['second'], array('attr' => array('size' => 1)));
         }
     ?>
 </div>

+ 2 - 2
src/Symfony/Bundle/TwigBundle/Resources/views/div_layout.html.twig

@@ -43,7 +43,7 @@
 
 {% block attributes %}
 {% spaceless %}
-    id="{{ id }}" name="{{ name }}"{% if class %} class="{{ class }}"{% endif %}{% if read_only %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}{% if size %} size="{{ size }}"{% endif %}
+    id="{{ id }}" name="{{ name }}"{% if class %} class="{{ class }}"{% endif %}{% if read_only %} disabled="disabled"{% endif %}{% if required %} required="required"{% endif %}{% if max_length %} maxlength="{{ max_length }}"{% endif %}
     {% for attrname,attrvalue in attr %}{{attrname}}="{{attrvalue}}" {% endfor %}
 {% endspaceless %}
 {% endblock attributes %}
@@ -168,7 +168,7 @@
 {% block time__widget %}
 {% spaceless %}
     <div {{ block('attributes') }}>
-        {{ form_widget(form.hour, { 'size': '1' }) }}:{{ form_widget(form.minute, { 'size': '1' }) }}{% if with_seconds %}:{{ form_widget(form.second, { '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 %}
     </div>
 {% endspaceless %}
 {% endblock time__widget %}

+ 5 - 0
tests/Symfony/Tests/Component/Form/AbstractLayoutTest.php

@@ -816,9 +816,11 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
     [
         ./select
             [@id="name_hour"]
+            [@size="1"]
             [./option[@value="4"][@selected="selected"]]
         /following-sibling::select
             [@id="name_minute"]
+            [@size="1"]
             [./option[@value="5"][@selected="selected"]]
     ]
     [count(./select)=2]
@@ -839,12 +841,15 @@ abstract class AbstractLayoutTest extends \PHPUnit_Framework_TestCase
     [
         ./select
             [@id="name_hour"]
+            [@size="1"]
             [./option[@value="4"][@selected="selected"]]
         /following-sibling::select
             [@id="name_minute"]
+            [@size="1"]
             [./option[@value="5"][@selected="selected"]]
         /following-sibling::select
             [@id="name_second"]
+            [@size="1"]
             [./option[@value="6"][@selected="selected"]]
     ]
     [count(./select)=3]