Fix for Issue #8847

Add attribute 'fieldset' to Form->radio
This commit is contained in:
xhs345 2016-05-18 10:53:06 -07:00
parent 326583153a
commit 615be3ad14

View file

@ -1510,6 +1510,7 @@ class FormHelper extends AppHelper {
* - `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
@ -1544,6 +1545,12 @@ class FormHelper extends AppHelper {
$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'];
@ -1638,7 +1645,12 @@ class FormHelper extends AppHelper {
$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;
}