diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 3a1db1a20..a2e2258bd 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -444,8 +444,8 @@ class FormHelper extends AppHelper { unset($fields['fieldset']); } } elseif ($fields !== null) { - $legend = $fields; - unset($fields); + $fieldset = $legend = $fields; + $fields = array(); } if (empty($fields)) { @@ -473,8 +473,10 @@ class FormHelper extends AppHelper { $out .= $this->input($name, $options); } - if ($fieldset) { + if ($fieldset && $legend) { return sprintf($this->Html->tags['fieldset'], $legend, $out); + } elseif ($fieldset) { + return sprintf("
%s
", $out); } else { return $out; } diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 7a3b8daa2..5a7053ab4 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -487,17 +487,24 @@ class FormHelperTest extends CakeTestCase { $result = $this->Form->inputs(); $this->assertPattern('/Edit Contact<\/legend>/', $result); - $result = $this->Form->inputs(array('fieldset' => true, 'legend' => false)); - $this->assertPattern('/]*>/', $result); - $this->assertNoPattern('/[^<>]+<\/legend>/', $result); + $result = $this->Form->inputs(false); + $this->assertNoPattern('/]*>/', $result); + $this->assertNoPattern('/[^<>]*<\/legend>/', $result); $result = $this->Form->inputs(array('fieldset' => false, 'legend' => false)); $this->assertNoPattern('/]*>/', $result); - $this->assertNoPattern('/[^<>]+<\/legend>/', $result); + $this->assertNoPattern('/[^<>]*<\/legend>/', $result); + + $result = $this->Form->inputs(array('fieldset' => true, 'legend' => false)); + $this->assertPattern('/]*>/', $result); + $this->assertNoPattern('/[^<>]*<\/legend>/', $result); $result = $this->Form->inputs(array('fieldset' => false, 'legend' => 'Hello')); $this->assertNoPattern('/]*>/', $result); - $this->assertNoPattern('/[^<>]+<\/legend>/', $result); + $this->assertNoPattern('/[^<>]*<\/legend>/', $result); + + $result = $this->Form->inputs('Hello'); + $this->assertPattern('/^
]*>Hello<\/legend>.+<\/fieldset>$/s', $result); $result = $this->Form->inputs(array('legend' => 'Hello')); $this->assertPattern('/^
]*>Hello<\/legend>.+<\/fieldset>$/s', $result);