Skip to content

Commit

Permalink
Only clear the unlocked fields on end().
Browse files Browse the repository at this point in the history
Doing this work on end() allows fields to be unlocked before the form is
created which can be helpful.

Refs #8880
  • Loading branch information
markstory committed May 25, 2016
1 parent b15560e commit e78af35
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion lib/Cake/Test/Case/View/Helper/FormHelperTest.php
Expand Up @@ -1608,8 +1608,10 @@ public function testResetUnlockFields() {
'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');
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -467,7 +467,6 @@ 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 Expand Up @@ -561,6 +560,7 @@ public function end($options = null, $secureAttributes = array()) {
$this->setEntity(null);
$out .= $this->Html->useTag('formend');

$this->_unlockedFields = array();
$this->_View->modelScope = false;
$this->requestType = null;
return $out;
Expand Down

0 comments on commit e78af35

Please sign in to comment.