Merge branch 'luksm-master'

Closes #GH-1352
This commit is contained in:
mark_story 2013-06-19 15:07:27 -04:00
commit 3867dec513
2 changed files with 27 additions and 0 deletions

View file

@ -6628,6 +6628,30 @@ class FormHelperTest extends CakeTestCase {
$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
*

View file

@ -2360,6 +2360,9 @@ class FormHelper extends AppHelper {
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'])) {