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("
", $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('/