Skip to content

Commit 615be3a

Browse files
author
xhs345
committed
Fix for Issue #8847
Add attribute 'fieldset' to Form->radio
1 parent 3265831 commit 615be3a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lib/Cake/View/Helper/FormHelper.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,7 @@ public function checkbox($fieldName, $options = array()) {
15101510
* - `between` - the string between legend and input set or array of strings to insert
15111511
* strings between each input block
15121512
* - `legend` - control whether or not the widget set has a fieldset & legend
1513+
* - `fieldset` - sets the class of the fieldset. Fieldset is only generated if legend attribute is provided
15131514
* - `value` - indicate a value that is should be checked
15141515
* - `label` - boolean to indicate whether or not labels for widgets show be displayed
15151516
* - `hiddenField` - boolean to indicate if you want the results of radio() to include
@@ -1544,6 +1545,12 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
15441545
$legend = __(Inflector::humanize($this->field()));
15451546
}
15461547

1548+
$fieldset = '';
1549+
if (isset($attributes['fieldset'])) {
1550+
$fieldset = $attributes['fieldset'];
1551+
unset($attributes['fieldset']);
1552+
}
1553+
15471554
$label = true;
15481555
if (isset($attributes['label'])) {
15491556
$label = $attributes['label'];
@@ -1638,7 +1645,12 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
16381645
$between = '';
16391646
}
16401647
if ($legend) {
1641-
$out = $this->Html->useTag('fieldset', '', $this->Html->useTag('legend', $legend) . $between . $out);
1648+
if (is_string($fieldset)) {
1649+
$fieldsetClass = sprintf(' class="%s"', $fieldset);
1650+
} else {
1651+
$fieldsetClass = '';
1652+
}
1653+
$out = $this->Html->useTag('fieldset', $fieldsetClass, $this->Html->useTag('legend', $legend) . $between . $out);
16421654
}
16431655
return $out;
16441656
}

0 commit comments

Comments
 (0)