fixes reset FormHelper::$_unlockFields

This commit is contained in:
nojimage 2016-05-21 13:33:20 +09:00
parent 78cda8c25d
commit 850305a384
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

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