Skip to content

Commit

Permalink
Apply patch from 'Eärendil' to fix FormHelper.
Browse files Browse the repository at this point in the history
Fixes Model.field.1 style fields when used with SecurityComponent.
Fixes #2011
  • Loading branch information
markstory committed Sep 23, 2011
1 parent 6a05cad commit a65a5eb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cake/libs/view/helpers/form.php
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -997,6 +997,20 @@ function testFormSecurityMultipleInputFields() {
$this->assertTags($result, $expected);
}

/**
* 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
*
Expand Down

0 comments on commit a65a5eb

Please sign in to comment.