Skip to content

Commit

Permalink
Merge branch 'luksm-master'
Browse files Browse the repository at this point in the history
Closes #GH-1352
  • Loading branch information
markstory committed Jun 19, 2013
2 parents 691288a + 68db74d commit 3867dec
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -6628,6 +6628,30 @@ public function testYearAutoExpandRange() {
$this->assertEquals($result, $expected);
}

/**
* testInputDateMaxYear method
*
* Let's say we want to only allow users born from 2006 to 2008 to register
* This being the first singup page, we still don't have any data
*
* @return void
*/
public function testInputDateMaxYear() {
$this->Form->request->data = array();
$this->Form->create('User');
$result = $this->Form->input('birthday',
array(
'label' => false,
'div' => false,
'type' => 'date',
'dateFormat' => 'DMY',
'minYear' => 2006,
'maxYear' => 2008
)
);
$this->assertContains('value="2008" selected="selected"', $result);
}

/**
* testTextArea method
*
Expand Down
3 changes: 3 additions & 0 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -2360,6 +2360,9 @@ public function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $a

if ($attributes['value'] === null && $attributes['empty'] != true) {
$attributes['value'] = time();
if (!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) {
$attributes['value'] = strtotime(date($attributes['maxYear'] . '-m-d'));
}
}

if (!empty($attributes['value'])) {
Expand Down

0 comments on commit 3867dec

Please sign in to comment.