Only clear the unlocked fields on end().

Doing this work on end() allows fields to be unlocked before the form is
created which can be helpful.

Refs #8880
This commit is contained in:
mark_story 2016-05-25 23:04:53 +02:00
parent b15560ea0c
commit e78af35af7
2 changed files with 4 additions and 2 deletions

View file

@ -1608,8 +1608,10 @@ class FormHelperTest extends CakeTestCase {
'unlockedFields' => array()
);
$this->Form->create('Contact');
$this->Form->unlockField('Contact.id');
$this->Form->create('Contact');
$this->Form->hidden('Contact.id', array('value' => 1));
$this->assertEmpty($this->Form->fields, 'Field should be unlocked');
$this->Form->end();
$this->Form->create('Contact');

View file

@ -467,7 +467,6 @@ class FormHelper extends AppHelper {
$htmlAttributes = array_merge($options, $htmlAttributes);
$this->fields = array();
$this->_unlockedFields = array();
if ($this->requestType !== 'get') {
$append .= $this->_csrfField();
}
@ -561,6 +560,7 @@ class FormHelper extends AppHelper {
$this->setEntity(null);
$out .= $this->Html->useTag('formend');
$this->_unlockedFields = array();
$this->_View->modelScope = false;
$this->requestType = null;
return $out;