Skip to content

Commit 850305a

Browse files
committed
fixes reset FormHelper::$_unlockFields
1 parent 78cda8c commit 850305a

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

lib/Cake/Test/Case/View/Helper/FormHelperTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,6 +1597,26 @@ public function testUnlockFieldRemovingFromFields() {
15971597
$this->assertEquals(array(), $this->Form->fields);
15981598
}
15991599

1600+
/**
1601+
* test reset unlockFields, when create new form.
1602+
*
1603+
* @return void
1604+
*/
1605+
public function testResetUnlockFields() {
1606+
$this->Form->request['_Token'] = array(
1607+
'key' => 'testKey',
1608+
'unlockedFields' => array()
1609+
);
1610+
1611+
$this->Form->create('Contact');
1612+
$this->Form->unlockField('Contact.id');
1613+
$this->Form->end();
1614+
1615+
$this->Form->create('Contact');
1616+
$this->Form->hidden('Contact.id', array('value' => 1));
1617+
$this->assertEquals(1, $this->Form->fields['Contact.id'], 'Hidden input should be secured.');
1618+
}
1619+
16001620
/**
16011621
* testTagIsInvalid method
16021622
*

lib/Cake/View/Helper/FormHelper.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ public function create($model = null, $options = array()) {
466466
$htmlAttributes = array_merge($options, $htmlAttributes);
467467

468468
$this->fields = array();
469+
$this->_unlockedFields = array();
469470
if ($this->requestType !== 'get') {
470471
$append .= $this->_csrfField();
471472
}

0 commit comments

Comments
 (0)