Permalink
Browse files

Allowing name attribute to pass on to hidden field in FormHelper::rad…

…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...
1 parent 377108f commit 8db4fe682bf6f1e406943df9cd5a72582c36e919 @markstory markstory committed Apr 15, 2009
Showing with 21 additions and 1 deletion.
  1. +1 −1 cake/libs/view/helpers/form.php
  2. +20 −0 cake/tests/cases/libs/view/helpers/form.test.php
@@ -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);
@@ -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

0 comments on commit 8db4fe6

Please sign in to comment.