Skip to content
Permalink
Browse files

Fixing issue in FormHelper where CURRENT_TIMESTAMP or other invalid d…

…ata could cause a notice error. Fixes #1508
  • Loading branch information...
markstory committed Feb 5, 2011
1 parent f381234 commit cf50cbdd9d40595a2cd32768888467fe5c374d99
Showing with 15 additions and 2 deletions.
  1. +5 −2 cake/libs/view/helpers/form.php
  2. +10 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -1843,8 +1843,11 @@ function dateTime($fieldName, $dateFormat = 'DMY', $timeFormat = '12', $selected
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];
}
}
}
}
@@ -4494,6 +4494,16 @@ function testDatetimeWithDefault() {
$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
*

0 comments on commit cf50cbd

Please sign in to comment.
You can’t perform that action at this time.