Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Rewrote class attribute assignment
  • Loading branch information
xhs345 committed May 19, 2016
1 parent 615be3a commit dcd7563
Showing 1 changed file with 11 additions and 15 deletions.
26 changes: 11 additions & 15 deletions lib/Cake/View/Helper/FormHelper.php
Expand Up @@ -932,11 +932,14 @@ public function inputs($fields = null, $blacklist = null, $options = array()) {

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;
}
Expand Down Expand Up @@ -971,17 +974,13 @@ public function inputs($fields = null, $blacklist = null, $options = array()) {
$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;
}
Expand Down Expand Up @@ -1545,9 +1544,9 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
$legend = __(Inflector::humanize($this->field()));
}

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

Expand Down Expand Up @@ -1644,13 +1643,10 @@ public function radio($fieldName, $options = array(), $attributes = array()) {
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;
}
Expand Down

0 comments on commit dcd7563

Please sign in to comment.