Merge pull request #8880 from nojimage/form-unlockfields-2x

Reset FormHelper::$_unlockFields for 2.x
This commit is contained in:
Mark Story 2016-05-25 22:59:25 +02:00
commit b15560ea0c
2 changed files with 21 additions and 0 deletions

View file

@ -1597,6 +1597,26 @@ class FormHelperTest extends CakeTestCase {
$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
*

View file

@ -467,6 +467,7 @@ class FormHelper extends AppHelper {
$htmlAttributes = array_merge($options, $htmlAttributes);
$this->fields = array();
$this->_unlockedFields = array();
if ($this->requestType !== 'get') {
$append .= $this->_csrfField();
}