Browse Source

Fix empty options not being set for single datetime inputs.

String and boolean values should be propagated into the component
pickers.

Refs #5818
Mark Story 11 years ago
parent
commit
11719e906d
2 changed files with 16 additions and 2 deletions
  1. 1 2
      src/View/Helper/FormHelper.php
  2. 15 0
      tests/TestCase/View/Helper/FormHelperTest.php

+ 1 - 2
src/View/Helper/FormHelper.php

@@ -2143,9 +2143,8 @@ class FormHelper extends Helper
                 $options[$type] = [];
             }
 
-            // Pass empty boolean to each type.
+            // Pass empty options to each type.
             if (!empty($options['empty']) &&
-                is_bool($options['empty']) &&
                 is_array($options[$type])
             ) {
                 $options[$type]['empty'] = $options['empty'];

+ 15 - 0
tests/TestCase/View/Helper/FormHelperTest.php

@@ -5178,6 +5178,11 @@ class FormHelperTest extends TestCase
             '*/select',
         ];
         $this->assertHtml($expected, $result);
+
+        $result = $this->Form->month('Contact.published', [
+            'empty' => 'Published on',
+        ]);
+        $this->assertContains('Published on', $result);
     }
 
     /**
@@ -5268,6 +5273,11 @@ class FormHelperTest extends TestCase
             '/select',
         ];
         $this->assertHtml($expected, $result);
+
+        $result = $this->Form->day('Contact.published', [
+            'empty' => 'Published on',
+        ]);
+        $this->assertContains('Published on', $result);
     }
 
     /**
@@ -5545,6 +5555,11 @@ class FormHelperTest extends TestCase
             '/select',
         ];
         $this->assertHtml($expected, $result);
+
+        $result = $this->Form->year('Contact.published', [
+            'empty' => 'Published on',
+        ]);
+        $this->assertContains('Published on', $result);
     }
 
     /**