فهرست منبع

[Form] Updated DateTimeType to accept a custom date pattern for the DateType child
* Added a test also about this change

Matthieu Vachon 14 سال پیش
والد
کامیت
954bdb5813

+ 0 - 7
src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

@@ -127,13 +127,6 @@ class DateTimeType extends AbstractType
                 'text',
                 'choice',
             ),
-            'date_format'   => array(
-                null, // inherit default from DateType
-                \IntlDateFormatter::FULL,
-                \IntlDateFormatter::LONG,
-                \IntlDateFormatter::MEDIUM,
-                \IntlDateFormatter::SHORT,
-             ),
             'time_widget'   => array(
                 null, // inherit default from TimeType
                 'text',

+ 22 - 0
tests/Symfony/Tests/Component/Form/Extension/Core/Type/DateTimeTypeTest.php

@@ -160,4 +160,26 @@ class DateTimeTypeTest extends LocalizedTestCase
 
         $this->assertEquals($dateTime->format('Y-m-d H:i:s'), $form->getData());
     }
+
+    public function testSubmit_differentPattern()
+    {
+        $form = $this->factory->create('datetime', null, array(
+            'date_format' => 'MM*yyyy*dd',
+            'date_widget' => 'single_text',
+            'time_widget' => 'text',
+            'input' => 'datetime',
+        ));
+
+        $dateTime = new \DateTime('2010-06-02 03:04');
+        
+        $form->bind(array(
+        	'date' => '06*2010*02',
+            'time' => array(
+                'hour' => '03',
+                'minute' => '04',
+            ),
+        ));
+
+        $this->assertDateTimeEquals($dateTime, $form->getData());
+    }
 }