Updating formHelper::dateTime() to work correctly with string timestamp values. Closes #5621

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7781 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mark_story 2008-10-26 14:53:06 +00:00
parent 1c9b1d0d78
commit 2d1483e1e5
2 changed files with 9 additions and 1 deletions

View file

@ -1467,7 +1467,7 @@ class FormHelper extends AppHelper {
if (is_array($selected)) {
extract($selected);
} else {
if (is_int($selected)) {
if (is_numeric($selected)) {
$selected = strftime('%Y-%m-%d %H:%M:%S', $selected);
}
$meridian = 'am';

View file

@ -3165,6 +3165,14 @@ class FormHelperTest extends CakeTestCase {
'*/select'
);
$this->assertTags($result, $expected);
$selected = '1225031586';
$result = $this->Form->dateTime('Model.field', 'DMY', '12', $selected);
$this->assertPattern('/<option[^<>]+value="2008"[^<>]+selected="selected"[^>]*>2008<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="10"[^<>]+selected="selected"[^>]*>10<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="26"[^<>]+selected="selected"[^>]*>26<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="10"[^<>]+selected="selected"[^>]*>10<\/option>/', $result);
$this->assertPattern('/<option[^<>]+value="33"[^<>]+selected="selected"[^>]*>33<\/option>/', $result);
$this->Form->create('Contact');
$result = $this->Form->input('published');