From fdeb41a826c6d01d3b04eea4f1ff59b5061a87df Mon Sep 17 00:00:00 2001 From: gwoo Date: Sun, 30 Dec 2007 18:25:00 +0000 Subject: [PATCH] updating FormHelper::inputs(), fixes #3770, tests updated git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6280 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/libs/view/helpers/form.php | 8 +++++--- .../tests/cases/libs/view/helpers/form.test.php | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) 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);