Skip to content
Permalink
Browse files

Fix hiddenField for radio.

Make hiddenField options work as documented for radio buttons. This is
a forward port of #11021 to 3.x

Refs #11002
  • Loading branch information...
markstory committed Aug 9, 2017
1 parent 15bf955 commit 3f568e0716961d4fe9640d89913bef942ca90d5b
Showing with 19 additions and 1 deletion.
  1. +1 −1 src/View/Helper/FormHelper.php
  2. +18 −0 tests/TestCase/View/Helper/FormHelperTest.php
@@ -1586,7 +1586,7 @@ public function radio($fieldName, $options = [], array $attributes = [])
$hidden = '';
if ($hiddenField) {
$hidden = $this->hidden($fieldName, [
'value' => '',
'value' => $hiddenField === true ? '' : $hiddenField,
'form' => isset($attributes['form']) ? $attributes['form'] : null,
'name' => $attributes['name'],
]);
@@ -4693,6 +4693,24 @@ public function testRadioDefaultValue()
$this->assertHtml($expected, $result);
}
/**
* Test setting a hiddenField value on radio buttons.
*
* @return void
*/
public function testRadioHiddenFieldValue()
{
$result = $this->Form->radio('title', ['option A'], ['hiddenField' => 'N']);
$expected = [
['input' => ['type' => 'hidden', 'name' => 'title', 'value' => 'N']],
'label' => ['for' => 'title-0'],
['input' => ['type' => 'radio', 'name' => 'title', 'value' => '0', 'id' => 'title-0']],
'option A',
'/label',
];
$this->assertHtml($expected, $result);
}
/**
* testControlRadio method
*

0 comments on commit 3f568e0

Please sign in to comment.
You can’t perform that action at this time.