From 850305a3840adfb1cb8d8b029f6958613fac4ed5 Mon Sep 17 00:00:00 2001 From: nojimage Date: Sat, 21 May 2016 13:33:20 +0900 Subject: [PATCH] fixes reset FormHelper::$_unlockFields --- .../Test/Case/View/Helper/FormHelperTest.php | 20 +++++++++++++++++++ lib/Cake/View/Helper/FormHelper.php | 1 + 2 files changed, 21 insertions(+) diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 2ca621712..b478abff8 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -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 * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 5d583a9c4..72c248785 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -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(); }