diff --git a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php index 78c5c4526..40a147782 100644 --- a/lib/Cake/Test/Case/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/FormHelperTest.php @@ -4944,6 +4944,30 @@ class FormHelperTest extends CakeTestCase { $this->assertTags($result, $expected); } +/** + * test setting a hiddenField value + * + * @return void + */ + public function testRadioHiddenFieldValue() { + $result = $this->Form->input('Model.1.field', array( + 'type' => 'radio', + 'options' => array('option A'), + 'hiddenField' => 'N' + ) + ); + $expected = array( + 'div' => array('class' => 'input radio'), + array('input' => array('type' => 'hidden', 'name' => 'data[Model][1][field]', 'value' => 'N', 'id' => 'Model1Field_')), + array('input' => array('type' => 'radio', 'name' => 'data[Model][1][field]', 'value' => '0', 'id' => 'Model1Field0')), + 'label' => array('for' => 'Model1Field0'), + 'option A', + '/label', + '/div' + ); + $this->assertTags($result, $expected); + } + /** * test adding an empty option for radio buttons * diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 61ec241c3..8a15e1d7a 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -1674,7 +1674,7 @@ class FormHelper extends AppHelper { $hidden = $this->hidden($fieldName, array( 'form' => isset($attributes['form']) ? $attributes['form'] : null, 'id' => $attributes['id'] . '_', - 'value' => '', + 'value' => $hiddenField === true ? '' : $hiddenField, 'name' => $attributes['name'] )); }