From 11719e906d892d188701b7e9e2f29c8a6befda16 Mon Sep 17 00:00:00 2001 From: Mark Story Date: Mon, 2 Feb 2015 22:45:01 -0500 Subject: [PATCH] Fix empty options not being set for single datetime inputs. String and boolean values should be propagated into the component pickers. Refs #5818 --- src/View/Helper/FormHelper.php | 3 +-- tests/TestCase/View/Helper/FormHelperTest.php | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index 2f049ef22d8..af332a6547c 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -2143,9 +2143,8 @@ protected function _datetimeOptions($options) $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']; diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index 971cab297b2..d56274f1dcb 100644 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -5178,6 +5178,11 @@ public function testMonth() '*/select', ]; $this->assertHtml($expected, $result); + + $result = $this->Form->month('Contact.published', [ + 'empty' => 'Published on', + ]); + $this->assertContains('Published on', $result); } /** @@ -5268,6 +5273,11 @@ public function testDay() '/select', ]; $this->assertHtml($expected, $result); + + $result = $this->Form->day('Contact.published', [ + 'empty' => 'Published on', + ]); + $this->assertContains('Published on', $result); } /** @@ -5545,6 +5555,11 @@ public function testYear() '/select', ]; $this->assertHtml($expected, $result); + + $result = $this->Form->year('Contact.published', [ + 'empty' => 'Published on', + ]); + $this->assertContains('Published on', $result); } /**