Cleanup from previous commit.

Refs #GH-1352
This commit is contained in:
mark_story 2013-06-19 15:06:51 -04:00
parent dc3f9113b0
commit 68db74d32d
2 changed files with 18 additions and 20 deletions

View file

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

View file

@ -2359,10 +2359,9 @@ class FormHelper extends AppHelper {
} }
if ($attributes['value'] === null && $attributes['empty'] != true) { if ($attributes['value'] === null && $attributes['empty'] != true) {
if(!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) { $attributes['value'] = time();
if (!empty($attributes['maxYear']) && $attributes['maxYear'] < date('Y')) {
$attributes['value'] = strtotime(date($attributes['maxYear'] . '-m-d')); $attributes['value'] = strtotime(date($attributes['maxYear'] . '-m-d'));
} else {
$attributes['value'] = time();
} }
} }