Permalink
Browse files

Fix nested name attributes for submit()

Nested name attributes and Security component did not co-operate.

Fixes #2271
  • Loading branch information...
markstory committed Nov 24, 2011
1 parent 0cd45d4 commit 07462f0bef316983d8a888b6e4243a40fa42fee4
Showing with 17 additions and 1 deletion.
  1. +15 −0 lib/Cake/Test/Case/View/Helper/FormHelperTest.php
  2. +2 −1 lib/Cake/View/Helper/FormHelper.php
@@ -975,6 +975,21 @@ public function testSecurityButtonNestedNamed() {
$this->assertEquals(array('Address.button'), $result);
}
/**
* Test that submit inputs created with foo[bar] name attributes are unlocked correctly.
*
* @return void
*/
public function testSecuritySubmitNestedNamed() {
$key = 'testKey';
$this->Form->request['_Token'] = array('key' => $key);
$this->Form->create('Addresses');
$this->Form->submit('Test', array('type' => 'submit', 'name' => 'Address[button]'));
$result = $this->Form->unlockField();
$this->assertEquals(array('Address.button'), $result);
}
/**
* Test that the correct fields are unlocked for image submits with no names.
*
@@ -1611,7 +1611,8 @@ public function submit($caption = null, $options = array()) {
}
if (isset($options['name'])) {
$this->_secure($options['secure'], $options['name']);
$name = str_replace(array('[', ']'), array('.', ''), $options['name']);
$this->_secure($options['secure'], $name);
}
unset($options['secure']);

0 comments on commit 07462f0

Please sign in to comment.