From d4c5eea261e8f6036dcc05fd2eb126b1b50a1ab8 Mon Sep 17 00:00:00 2001 From: dho Date: Sun, 1 Apr 2007 14:31:23 +0000 Subject: [PATCH] Adding patch from ticket #2324 plus test git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4731 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/form.php | 2 +- cake/tests/cases/libs/view/helpers/form.test.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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');