From e78af35af77348549b56ba222339c290f23a880b Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 25 May 2016 23:04:53 +0200 Subject: [PATCH] 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 --- lib/Cake/Test/Case/View/Helper/FormHelperTest.php | 4 +++- lib/Cake/View/Helper/FormHelper.php | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index a30cc919f..f72ea120d 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -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'); diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 31b18010f..2282a38e5 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -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;