diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index bc634992d..e6e73bf1b 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -693,7 +693,7 @@ class FormHelper extends AppHelper { if (empty($selected) && !$showEmpty) { $selected = date('Y'); } - return $this->select($fieldName . "_year", $this->__generateOptions('year'), $selected, $attributes, $showEmpty); + return $this->select($fieldName . "_year", $this->__generateOptions('year', $minYear, $maxYear), $selected, $attributes, $showEmpty); } /** * Returns a SELECT element for months. diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index ec77c7565..e33c76b16 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -223,6 +223,14 @@ class FormHelperTest extends UnitTestCase { } + function testYear() { + $result = $this->Form->year('Model.field', 2006, 2007); + $this->assertPattern('/option value="2006"/', $result); + $this->assertPattern('/option value="2007"/', $result); + $this->assertNoPattern('/option value="2005"/', $result); + $this->assertNoPattern('/option value="2008"/', $result); + } + function testTextArea() { $this->Form->data = array('Model' => array('field' => 'some test data')); $result = $this->Form->textarea('Model/field');