Permalink
Browse files

Fixing Form::dateTime() for GET forms. Tests added. Fixes #522

  • Loading branch information...
1 parent f56e24c commit 46c4cab95bd10855ed607d983bd39d5a3e5f9fe4 @markstory markstory committed Apr 2, 2010
Showing with 23 additions and 1 deletion.
  1. +6 −1 cake/libs/view/helpers/form.php
  2. +17 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -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;
@@ -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
*

0 comments on commit 46c4cab

Please sign in to comment.