Skip to content

Commit

Permalink
Fixing Form::dateTime() for GET forms. Tests added. Fixes #522
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Apr 2, 2010
1 parent f56e24c commit 46c4cab
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cake/libs/view/helpers/form.php
Expand Up @@ -1673,7 +1673,12 @@ function __name($options = array(), $field = null, $key = 'name') {
if (is_array($options) && isset($options[$key])) {
return $options;
}
$name = $this->field();

$view = ClassRegistry::getObject('view');
$name = $view->field;
if (!empty($view->fieldSuffix)) {
$name .= '[' . $view->fieldSuffix . ']';
}

if (is_array($options)) {
$options[$key] = $name;
Expand Down
17 changes: 17 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -4702,6 +4702,23 @@ function testGetFormCreate() {
'name' => 'user_form', 'type' => 'text', 'value' => '', 'id' => 'ContactUserForm'
)));
}
/**
* test that datetime() works with GET style forms.
*
* @return void
*/
function testDateTimeWithGetForms() {
extract($this->dateRegex);
$this->Form->create('Contact', array('type' => 'get'));
$result = $this->Form->datetime('created');

$this->assertPattern('/name="created\[year\]"/', $result, 'year name attribute is wrong.');
$this->assertPattern('/name="created\[month\]"/', $result, 'month name attribute is wrong.');
$this->assertPattern('/name="created\[day\]"/', $result, 'day name attribute is wrong.');
$this->assertPattern('/name="created\[hour\]"/', $result, 'hour name attribute is wrong.');
$this->assertPattern('/name="created\[min\]"/', $result, 'min name attribute is wrong.');
$this->assertPattern('/name="created\[meridian\]"/', $result, 'meridian name attribute is wrong.');
}
/**
* testEditFormWithData method
*
Expand Down

0 comments on commit 46c4cab

Please sign in to comment.