Fixing issue in FormHelper where CURRENT_TIMESTAMP or other invalid data could cause a notice error. Fixes #1508

This commit is contained in:
mark_story 2011-02-05 06:43:00 -05:00
parent f3812342c2
commit cf50cbdd9d
2 changed files with 15 additions and 2 deletions

View file

@ -1843,8 +1843,11 @@ class FormHelper extends AppHelper {
if ($time[0] == 0 && $timeFormat == '12') {
$time[0] = 12;
}
$hour = $time[0];
$min = $time[1];
$hour = $min = null;
if (isset($time[1])) {
$hour = $time[0];
$min = $time[1];
}
}
}
}

View file

@ -4494,6 +4494,16 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/<option[^<>]+value="06"[^<>]+selected="selected"[^>]*>June<\/option>/', $result);
}
/**
* test that bogus non-date time data doesn't cause errors.
*
* @return void
*/
function testDateTimeWithBogusData() {
$result = $this->Form->dateTime('Contact.updated', 'DMY', '12', 'CURRENT_TIMESTAMP');
$this->assertNoPattern('/selected="selected">\d/', $result);
}
/**
* testFormDateTimeMulti method
*