Skip to content

Commit 417bfd8

Browse files
committed
Remove legend/fieldset classnames.
This formatting should be handled with templates now.
1 parent 6d1c29f commit 417bfd8

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/View/Helper/FormHelper.php

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,13 @@ class FormHelper extends Helper {
142142
'errorList' => '<ul>{{content}}</ul>',
143143
'errorItem' => '<li>{{text}}</li>',
144144
'file' => '<input type="file" name="{{name}}"{{attrs}}>',
145+
'fieldset' => '<fieldset>{{content}}</fieldset>',
145146
'formstart' => '<form{{attrs}}>',
146147
'formend' => '</form>',
147148
'hiddenblock' => '<div style="display:none;">{{content}}</div>',
148149
'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}>',
149150
'label' => '<label{{attrs}}>{{text}}</label>',
151+
'legend' => '<legend>{{text}}</legend>',
150152
'option' => '<option value="{{value}}"{{attrs}}>{{text}}</option>',
151153
'optgroup' => '<optgroup label="{{label}}"{{attrs}}>{{content}}</optgroup>',
152154
'select' => '<select name="{{name}}"{{attrs}}>{{content}}</select>',
@@ -724,8 +726,7 @@ protected function _domId($value) {
724726
* @param array $fields An array of fields to generate inputs for, or null.
725727
* @param array $blacklist A simple array of fields to not create inputs for.
726728
* @param array $options Options array. Valid keys are:
727-
* - `fieldset` Set to false to disable the fieldset. If a string is supplied it will be used as
728-
* the class name for the fieldset element.
729+
* - `fieldset` Set to false to disable the fieldset.
729730
* - `legend` Set to false to disable the legend for the generated input set. Or supply a string
730731
* to customize the legend text.
731732
* @return string Completed form inputs.
@@ -794,18 +795,11 @@ public function inputs($fields = null, $blacklist = null, $options = array()) {
794795
$out .= $this->input($name, $options);
795796
}
796797

797-
if (is_string($fieldset)) {
798-
$fieldsetClass = sprintf(' class="%s"', $fieldset);
799-
} else {
800-
$fieldsetClass = '';
801-
}
802-
803-
// TODO cleanup HTML helper usage.
804798
if ($fieldset) {
805799
if ($legend) {
806-
$out = $this->Html->useTag('legend', $legend) . $out;
800+
$out = $this->formatTemplate('legend', ['text' => $legend]) . $out;
807801
}
808-
$out = $this->Html->useTag('fieldset', $fieldsetClass, $out);
802+
$out = $this->formatTemplate('fieldset', ['content' => $out]);
809803
}
810804
return $out;
811805
}

tests/TestCase/View/Helper/FormHelperTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2510,20 +2510,20 @@ public function testFormInputsLegendFieldset() {
25102510
);
25112511
$this->assertTags($result, $expected);
25122512

2513-
$result = $this->Form->inputs(array('legend' => 'Field of Dreams', 'fieldset' => 'classy-stuff'));
2513+
$result = $this->Form->inputs(array('legend' => 'Field of Dreams', 'fieldset' => true));
25142514
$expected = array(
2515-
'fieldset' => array('class' => 'classy-stuff'),
2515+
'<fieldset',
25162516
'<legend',
25172517
'Field of Dreams',
25182518
'/legend',
25192519
'*/fieldset'
25202520
);
25212521
$this->assertTags($result, $expected);
25222522

2523-
$result = $this->Form->inputs(null, null, array('legend' => 'Field of Dreams', 'fieldset' => 'classy-stuff'));
2523+
$result = $this->Form->inputs(null, null, array('legend' => 'Field of Dreams', 'fieldset' => true));
25242524
$this->assertTags($result, $expected);
25252525

2526-
$result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => 'classy-stuff'));
2526+
$result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => true));
25272527
$this->assertTags($result, $expected);
25282528

25292529
$this->Form->create($this->article);

0 commit comments

Comments
 (0)