Skip to content

Commit

Permalink
fixes reset FormHelper::$_unlockFields
Browse files Browse the repository at this point in the history
  • Loading branch information
nojimage committed May 21, 2016
1 parent 78cda8c commit 850305a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -1597,6 +1597,26 @@ public function testUnlockFieldRemovingFromFields() {
$this->assertEquals(array(), $this->Form->fields);
}

/**
* test reset unlockFields, when create new form.
*
* @return void
*/
public function testResetUnlockFields() {
$this->Form->request['_Token'] = array(
'key' => 'testKey',
'unlockedFields' => array()
);

$this->Form->create('Contact');
$this->Form->unlockField('Contact.id');
$this->Form->end();

$this->Form->create('Contact');
$this->Form->hidden('Contact.id', array('value' => 1));
$this->assertEquals(1, $this->Form->fields['Contact.id'], 'Hidden input should be secured.');
}

/**
* testTagIsInvalid method
*
Expand Down
1 change: 1 addition & 0 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -466,6 +466,7 @@ public function create($model = null, $options = array()) {
$htmlAttributes = array_merge($options, $htmlAttributes);

$this->fields = array();
$this->_unlockedFields = array();
if ($this->requestType !== 'get') {
$append .= $this->_csrfField();
}
Expand Down

0 comments on commit 850305a

Please sign in to comment.