From d124b6c05d5c279227efe009c295a4f578268cb8 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 20 Apr 2011 21:37:47 -0400 Subject: [PATCH] Removing `class` from being excluded from the attributes applied to hidden inputs. Fixes #1124 --- lib/Cake/View/Helper/FormHelper.php | 2 +- lib/Cake/tests/Case/View/Helper/FormHelperTest.php | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index f4744fcc5..b46f39c11 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1238,7 +1238,7 @@ class FormHelper extends AppHelper { $this->__secure(null, '' . $options['value']); } - return $this->Html->useTag('hidden', $options['name'], array_diff_key($options, array('name' => '', 'class' => ''))); + return $this->Html->useTag('hidden', $options['name'], array_diff_key($options, array('name' => ''))); } /** diff --git a/lib/Cake/tests/Case/View/Helper/FormHelperTest.php b/lib/Cake/tests/Case/View/Helper/FormHelperTest.php index 54771a105..a26a8fb4d 100644 --- a/lib/Cake/tests/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/tests/Case/View/Helper/FormHelperTest.php @@ -3687,7 +3687,7 @@ class FormHelperTest extends CakeTestCase { 'div' => false )); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), + 'input' => array('type' => 'hidden', 'class' => 'form-error', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), array('div' => array('class' => 'checkbox form-error')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')), array('label' => array('for' => 'ModelTags0')), @@ -3705,7 +3705,7 @@ class FormHelperTest extends CakeTestCase { 'div' => false )); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), + 'input' => array('type' => 'hidden', 'class' => 'form-error', 'name' => 'data[Model][tags]', 'value' => '', 'id' => 'ModelTags'), array('div' => array('class' => 'mycheckbox form-error')), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][tags][]', 'value' => '0', 'id' => 'ModelTags0')), array('label' => array('for' => 'ModelTags0')), @@ -3900,14 +3900,14 @@ class FormHelperTest extends CakeTestCase { $this->Form->request->data['Model']['field'] = 'myvalue'; $result = $this->Form->checkbox('Model.field', array('id' => 'theID', 'value' => 'myvalue')); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'theID_'), + 'input' => array('type' => 'hidden', 'class' => 'form-error', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'theID_'), array('input' => array('preg:/[^<]+/', 'value' => 'myvalue', 'id' => 'theID', 'checked' => 'checked', 'class' => 'form-error')) ); $this->assertTags($result, $expected); $result = $this->Form->checkbox('Model.field', array('value' => 'myvalue')); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'), + 'input' => array('type' => 'hidden', 'class' => 'form-error', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'ModelField_'), array('input' => array('preg:/[^<]+/', 'value' => 'myvalue', 'id' => 'ModelField', 'checked' => 'checked', 'class' => 'form-error')) ); $this->assertTags($result, $expected); @@ -3915,7 +3915,7 @@ class FormHelperTest extends CakeTestCase { $this->Form->request->data['Model']['field'] = ''; $result = $this->Form->checkbox('Model.field', array('id' => 'theID')); $expected = array( - 'input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'theID_'), + 'input' => array('type' => 'hidden', 'class' => 'form-error', 'name' => 'data[Model][field]', 'value' => '0', 'id' => 'theID_'), array('input' => array('type' => 'checkbox', 'name' => 'data[Model][field]', 'value' => '1', 'id' => 'theID', 'class' => 'form-error')) ); $this->assertTags($result, $expected); @@ -5316,7 +5316,9 @@ class FormHelperTest extends CakeTestCase { $this->Form->validationErrors['Model']['field'] = 1; $this->Form->request->data['Model']['field'] = 'test'; $result = $this->Form->hidden('Model.field', array('id' => 'theID')); - $this->assertTags($result, array('input' => array('type' => 'hidden', 'name' => 'data[Model][field]', 'id' => 'theID', 'value' => 'test'))); + $this->assertTags($result, array( + 'input' => array('type' => 'hidden', 'class' => 'form-error', 'name' => 'data[Model][field]', 'id' => 'theID', 'value' => 'test')) + ); } /**