Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove legend/fieldset classnames.

This formatting should be handled with templates now.
  • Loading branch information...
commit 417bfd8bbfff8ed1b1d3cb39d85ef7bb40db9ab9 1 parent 6d1c29f
@markstory markstory authored
View
16 src/View/Helper/FormHelper.php
@@ -142,11 +142,13 @@ class FormHelper extends Helper {
'errorList' => '<ul>{{content}}</ul>',
'errorItem' => '<li>{{text}}</li>',
'file' => '<input type="file" name="{{name}}"{{attrs}}>',
+ 'fieldset' => '<fieldset>{{content}}</fieldset>',
'formstart' => '<form{{attrs}}>',
'formend' => '</form>',
'hiddenblock' => '<div style="display:none;">{{content}}</div>',
'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}>',
'label' => '<label{{attrs}}>{{text}}</label>',
+ 'legend' => '<legend>{{text}}</legend>',
'option' => '<option value="{{value}}"{{attrs}}>{{text}}</option>',
'optgroup' => '<optgroup label="{{label}}"{{attrs}}>{{content}}</optgroup>',
'select' => '<select name="{{name}}"{{attrs}}>{{content}}</select>',
@@ -724,8 +726,7 @@ protected function _domId($value) {
* @param array $fields An array of fields to generate inputs for, or null.
* @param array $blacklist A simple array of fields to not create inputs for.
* @param array $options Options array. Valid keys are:
- * - `fieldset` Set to false to disable the fieldset. If a string is supplied it will be used as
- * the class name for the fieldset element.
+ * - `fieldset` Set to false to disable the fieldset.
* - `legend` Set to false to disable the legend for the generated input set. Or supply a string
* to customize the legend text.
* @return string Completed form inputs.
@@ -794,18 +795,11 @@ 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 = '';
- }
-
- // TODO cleanup HTML helper usage.
if ($fieldset) {
if ($legend) {
- $out = $this->Html->useTag('legend', $legend) . $out;
+ $out = $this->formatTemplate('legend', ['text' => $legend]) . $out;
}
- $out = $this->Html->useTag('fieldset', $fieldsetClass, $out);
+ $out = $this->formatTemplate('fieldset', ['content' => $out]);
}
return $out;
}
View
8 tests/TestCase/View/Helper/FormHelperTest.php
@@ -2510,9 +2510,9 @@ public function testFormInputsLegendFieldset() {
);
$this->assertTags($result, $expected);
- $result = $this->Form->inputs(array('legend' => 'Field of Dreams', 'fieldset' => 'classy-stuff'));
+ $result = $this->Form->inputs(array('legend' => 'Field of Dreams', 'fieldset' => true));
$expected = array(
- 'fieldset' => array('class' => 'classy-stuff'),
+ '<fieldset',
'<legend',
'Field of Dreams',
'/legend',
@@ -2520,10 +2520,10 @@ public function testFormInputsLegendFieldset() {
);
$this->assertTags($result, $expected);
- $result = $this->Form->inputs(null, null, array('legend' => 'Field of Dreams', 'fieldset' => 'classy-stuff'));
+ $result = $this->Form->inputs(null, null, array('legend' => 'Field of Dreams', 'fieldset' => true));
$this->assertTags($result, $expected);
- $result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => 'classy-stuff'));
+ $result = $this->Form->inputs('Field of Dreams', null, array('fieldset' => true));
$this->assertTags($result, $expected);
$this->Form->create($this->article);
Please sign in to comment.
Something went wrong with that request. Please try again.