diff --git a/lib/Cake/View/Helper/FormHelper.php b/lib/Cake/View/Helper/FormHelper.php index 974c54c65..99dbe0946 100644 --- a/lib/Cake/View/Helper/FormHelper.php +++ b/lib/Cake/View/Helper/FormHelper.php @@ -932,11 +932,14 @@ class FormHelper extends AppHelper { if (isset($options['legend'])) { $legend = $options['legend']; + unset($options['legend']); } if (isset($options['fieldset'])) { - $fieldset = $options['fieldset']; + $fieldsetAttrs = ['class' => $options['fieldset']]; + unset($options['fieldset']); } + if (empty($fields)) { $fields = $modelFields; } @@ -971,17 +974,13 @@ class FormHelper extends AppHelper { $out .= $this->input($name, $options); } - if (is_string($fieldset)) { - $fieldsetClass = sprintf(' class="%s"', $fieldset); - } else { - $fieldsetClass = ''; - } + if ($fieldset) { if ($legend) { $out = $this->Html->useTag('legend', $legend) . $out; } - $out = $this->Html->useTag('fieldset', $fieldsetClass, $out); + $out = $this->Html->useTag('fieldset', $fieldsetAttrs, $out); } return $out; } @@ -1545,9 +1544,9 @@ class FormHelper extends AppHelper { $legend = __(Inflector::humanize($this->field())); } - $fieldset = ''; + $fieldsetAttrs = ''; if (isset($attributes['fieldset'])) { - $fieldset = $attributes['fieldset']; + $fieldsetAttrs = ['class' => $attributes['fieldset']]; unset($attributes['fieldset']); } @@ -1644,13 +1643,10 @@ class FormHelper extends AppHelper { if (is_array($between)) { $between = ''; } + if ($legend) { - if (is_string($fieldset)) { - $fieldsetClass = sprintf(' class="%s"', $fieldset); - } else { - $fieldsetClass = ''; - } - $out = $this->Html->useTag('fieldset', $fieldsetClass, $this->Html->useTag('legend', $legend) . $between . $out); + $out = $this->Html->useTag('legend', $legend) . $between . $out; + $out = $this->Html->useTag('fieldset', $fieldsetAttrs, $out); } return $out; }