Skip to content
Permalink
Browse files

Port fixes in #7289 to 3.x

If a visible input is created after a hidden input was created, the
form would always blackhole unless the visible input had the same value
as the hidden input.
  • Loading branch information...
markstory committed Aug 23, 2015
1 parent 97ad888 commit 2173112e3aa671ae8fdbc796fa30bf8c3a076396
Showing with 27 additions and 0 deletions.
  1. +2 −0 src/View/Helper/FormHelper.php
  2. +25 −0 tests/TestCase/View/Helper/FormHelperTest.php
@@ -653,6 +653,8 @@ protected function _secure($lock, $field, $value = null)
if (!in_array($field, $this->fields)) {
if ($value !== null) {
return $this->fields[$field] = $value;
} elseif (isset($this->fields[$field]) && $value === null) {
unset($this->fields[$field]);
}
$this->fields[] = $field;
}
@@ -1666,6 +1666,31 @@ public function testSecuredInputCustomName()
$this->assertEquals($expected, $this->Form->fields);
}
/**
* Test that a hidden field followed by a visible field
* undoes the hidden field locking.
*
* @return void
*/
public function testSecuredInputDuplicate()
{
$this->Form->request->params['_Token'] = ['key' => 'testKey'];
$this->assertEquals([], $this->Form->fields);
$this->Form->input('text_val', [
'type' => 'hidden',
'value' => 'some text',
]);
$expected = ['text_val' => 'some text'];
$this->assertEquals($expected, $this->Form->fields);
$this->Form->input('text_val', [
'type' => 'text',
]);
$expected = ['text_val'];
$this->assertEquals($expected, $this->Form->fields);
}
/**
* Tests that the correct keys are added to the field hash index
*

0 comments on commit 2173112

Please sign in to comment.
You can’t perform that action at this time.