From 6620b3b8fcce070f603f37761d412ad908e012e3 Mon Sep 17 00:00:00 2001 From: Robert Sworder Date: Thu, 5 Aug 2010 23:00:15 +0100 Subject: [PATCH] month function + tests --- cake/libs/view/helpers/form.php | 8 ++++---- cake/tests/cases/libs/view/helpers/form.test.php | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index dcf8f20f3..79f1dc1cd 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -1581,14 +1581,13 @@ class FormHelper extends AppHelper { * that string is displayed as the empty element. * * @param string $fieldName Prefix name for the SELECT element - * @param string $selected Option which is selected. * @param array $attributes Attributes for the select element * @return string A generated month select dropdown. * @access public * @link http://book.cakephp.org/view/1417/month */ - public function month($fieldName, $selected = null, $attributes = array()) { - $attributes += array('empty' => true, 'value' => $selected); + public function month($fieldName, $attributes = array()) { + $attributes += array('empty' => true, 'value' => null); $attributes = $this->__dateTimeSelected('month', $fieldName, $attributes); if (strlen($attributes['value']) > 2) { @@ -1885,8 +1884,9 @@ class FormHelper extends AppHelper { ); break; case 'M': + $selectMonthAttr['value'] = $month; $selectMonthAttr['monthNames'] = $monthNames; - $selects[] = $this->month($fieldName, $month, $selectMonthAttr); + $selects[] = $this->month($fieldName, $selectMonthAttr); break; case 'D': $selectDayAttr['value'] = $day; diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index b0c565ac5..b73eb762a 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -4500,7 +4500,7 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->month('Model.field', null, array('empty' => true)); + $result = $this->Form->month('Model.field', array('empty' => true)); $expected = array( array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')), array('option' => array('value' => '')), @@ -4515,7 +4515,7 @@ class FormHelperTest extends CakeTestCase { ); $this->assertTags($result, $expected); - $result = $this->Form->month('Model.field', null, array('monthNames' => false)); + $result = $this->Form->month('Model.field', array('monthNames' => false)); $expected = array( array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')), array('option' => array('value' => '')), @@ -4533,7 +4533,7 @@ class FormHelperTest extends CakeTestCase { $monthNames = array( '01' => 'Jan', '02' => 'Feb', '03' => 'Mar', '04' => 'Apr', '05' => 'May', '06' => 'Jun', '07' => 'Jul', '08' => 'Aug', '09' => 'Sep', '10' => 'Oct', '11' => 'Nov', '12' => 'Dec'); - $result = $this->Form->month('Model.field', null, array('monthNames' => $monthNames)); + $result = $this->Form->month('Model.field', array('monthNames' => $monthNames)); $expected = array( array('select' => array('name' => 'data[Model][field][month]', 'id' => 'ModelFieldMonth')), array('option' => array('value' => '')),