diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index 70044039264..66294c020cd 100755 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -712,7 +712,7 @@ public function label($fieldName, $text = null, $options = array()) { } /** - * Generate a set of inputs for `$fields`. If $fields is null the fields of current model + * Generate a set of inputs for `$fields`. If $fields is empty the fields of current model * will be used. * * You can customize individual inputs through `$fields`. @@ -725,16 +725,12 @@ public function label($fieldName, $text = null, $options = array()) { * You can exclude fields using the `$blacklist` parameter: * * {{{ - * $this->Form->inputs(null, ['title']); + * $this->Form->inputs([], ['title']); * }}} * * In the above example, no field would be generated for the title field. * - * In addition to controller fields output, `$fields` can be used to control legend - * and fieldset rendering. - * `$this->Form->inputs('My legend');` Would generate an input set with a custom legend. - * - * @param mixed $fields An array of customizations for the fields that will be + * @param array $fields An array of customizations for the fields that will be * generated. This array allows you to set custom types, labels, or other options. * @param array $blacklist A list of fields to not create inputs for. * @param array $options Options array. Valid keys are: @@ -744,20 +740,12 @@ public function label($fieldName, $text = null, $options = array()) { * @return string Completed form inputs. * @link http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#FormHelper::inputs */ - public function inputs($fields = null, array $blacklist = [], array $options = []) { + public function inputs(array $fields = [], array $blacklist = [], array $options = []) { $fieldset = $legend = true; $context = $this->_getContext(); $modelFields = $context->fieldNames(); - if (is_string($fields)) { - $legend = $fields; - $fields = []; - } elseif (is_bool($fields)) { - $fieldset = $legend = $fields; - $fields = []; - } - $fields = array_merge( Hash::normalize($modelFields), Hash::normalize((array)$fields) diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index 7f8e8be16f2..d40890bf148 100755 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -2649,7 +2649,7 @@ public function testInputMagicSelectChangeToRadio() { */ public function testFormInputsLegendFieldset() { $this->Form->create($this->article); - $result = $this->Form->inputs('The Legend'); + $result = $this->Form->inputs([], [], array('legend' => 'The Legend')); $expected = array( 'assertTags($result, $expected); - $result = $this->Form->inputs(null, array(), array('legend' => 'Field of Dreams', 'fieldset' => true)); + $result = $this->Form->inputs([], [], array('fieldset' => true, 'legend' => 'Field of Dreams')); $this->assertContains('Field of Dreams', $result); $this->assertContains('
', $result); - $result = $this->Form->inputs('Field of Dreams', array(), array('fieldset' => true)); - $this->assertContains('Field of Dreams', $result); - $this->assertContains('
', $result); - - $result = $this->Form->inputs(null, array(), array('fieldset' => false, 'legend' => false)); + $result = $this->Form->inputs([], [], array('fieldset' => false, 'legend' => false)); $this->assertNotContains('', $result); $this->assertNotContains('
', $result); - $result = $this->Form->inputs(null, array(), array('fieldset' => false, 'legend' => 'Hello')); + $result = $this->Form->inputs([], [], array('fieldset' => false, 'legend' => 'Hello')); $this->assertNotContains('', $result); $this->assertNotContains('
', $result); @@ -2734,7 +2730,7 @@ public function testFormInputs() { $this->assertTags($result, $expected); $this->Form->create($this->article); - $result = $this->Form->inputs('Hello'); + $result = $this->Form->inputs([], [], ['legend' => 'Hello']); $expected = array( 'fieldset' => array(), 'legend' => array(),