Skip to content

Commit

Permalink
Allowing name attribute to pass on to hidden field in FormHelper::rad…
Browse files Browse the repository at this point in the history
…io().

Fixes inconsistency with checkbox().  Test case added.
Fixes #6260

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8145 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Apr 15, 2009
1 parent 377108f commit 8db4fe6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cake/libs/view/helpers/form.php
Expand Up @@ -934,7 +934,7 @@ function radio($fieldName, $options = array(), $attributes = array()) {

if (!isset($value) || $value === '') {
$hidden = $this->hidden($fieldName, array(
'id' => $attributes['id'] . '_', 'value' => ''
'id' => $attributes['id'] . '_', 'value' => '', 'name' => $attributes['name']
));
}
$out = $hidden . join($inbetween, $out);
Expand Down
20 changes: 20 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -2553,6 +2553,26 @@ function testRadio() {
'/label'
);
$this->assertTags($result, $expected);


$result = $this->Form->radio('Model.field', array('option A', 'option B'), array('name' => 'data[Model][custom]'));
$expected = array(
'fieldset' => array(),
'legend' => array(),
'Field',
'/legend',
'input' => array('type' => 'hidden', 'name' => 'data[Model][custom]', 'value' => '', 'id' => 'ModelField_'),
array('input' => array('type' => 'radio', 'name' => 'data[Model][custom]', 'value' => '0', 'id' => 'ModelField0')),
array('label' => array('for' => 'ModelField0')),
'option A',
'/label',
array('input' => array('type' => 'radio', 'name' => 'data[Model][custom]', 'value' => '1', 'id' => 'ModelField1')),
array('label' => array('for' => 'ModelField1')),
'option B',
'/label',
'/fieldset'
);
$this->assertTags($result, $expected);
}
/**
* testSelect method
Expand Down

0 comments on commit 8db4fe6

Please sign in to comment.