Permalink
Browse files

Apply patch from 'Eärendil' to fix FormHelper.

Fixes Model.field.1 style fields when used with SecurityComponent.
Fixes #2011
  • Loading branch information...
1 parent 6a05cad commit a65a5eb506c4c056646d5a9f015a9b1d4fb14e58 @markstory markstory committed Sep 23, 2011
Showing with 20 additions and 0 deletions.
  1. +6 −0 cake/libs/view/helpers/form.php
  2. +14 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -439,6 +439,12 @@ function __secure($field = null, $value = null) {
}
}
}
+
+ $last = end($field);
+ if (is_numeric($last) || empty($last)) {
+ array_pop($field);
+ }
+
$field = implode('.', $field);
if (!in_array($field, $this->fields)) {
if ($value !== null) {
@@ -998,6 +998,20 @@ function testFormSecurityMultipleInputFields() {
}
/**
+ * Test form security with Model.field.0 style inputs
+ *
+ * @return void
+ */
+ function testFormSecurityArrayFields() {
+ $key = 'testKey';
+
+ $this->Form->params['_Token']['key'] = $key;
+ $this->Form->create('Address');
+ $this->Form->input('Address.primary.1');
+ $this->assertEqual('Address.primary', $this->Form->fields[0]);
+ }
+
+/**
* testFormSecurityMultipleInputDisabledFields method
*
* test secure form generation with multiple records and disabled fields.

0 comments on commit a65a5eb

Please sign in to comment.