Skip to content

Commit

Permalink
Fix for Issue #8847
Browse files Browse the repository at this point in the history
Add attribute 'fieldset' to Form->radio
  • Loading branch information
xhs345 committed May 18, 2016
1 parent 3265831 commit 615be3a
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -1510,6 +1510,7 @@ public function checkbox($fieldName, $options = array()) {
* - `between` - the string between legend and input set or array of strings to insert
* strings between each input block
* - `legend` - control whether or not the widget set has a fieldset & legend
* - `fieldset` - sets the class of the fieldset. Fieldset is only generated if legend attribute is provided
* - `value` - indicate a value that is should be checked
* - `label` - boolean to indicate whether or not labels for widgets show be displayed
* - `hiddenField` - boolean to indicate if you want the results of radio() to include
Expand Down Expand Up @@ -1544,6 +1545,12 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
$legend = __(Inflector::humanize($this->field()));
}

$fieldset = '';
if (isset($attributes['fieldset'])) {
$fieldset = $attributes['fieldset'];
unset($attributes['fieldset']);
}

$label = true;
if (isset($attributes['label'])) {
$label = $attributes['label'];
Expand Down Expand Up @@ -1638,7 +1645,12 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
$between = '';
}
if ($legend) {
$out = $this->Html->useTag('fieldset', '', $this->Html->useTag('legend', $legend) . $between . $out);
if (is_string($fieldset)) {
$fieldsetClass = sprintf(' class="%s"', $fieldset);
} else {
$fieldsetClass = '';
}
$out = $this->Html->useTag('fieldset', $fieldsetClass, $this->Html->useTag('legend', $legend) . $between . $out);
}
return $out;
}
Expand Down

0 comments on commit 615be3a

Please sign in to comment.