diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index 2b4fa567d8a..beaff3f561c 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -1012,6 +1012,7 @@ public function input($fieldName, array $options = []) $label = $options['label']; unset($options['label']); + $nestedInput = false; if ($options['type'] === 'checkbox') { $nestedInput = true; @@ -1023,7 +1024,7 @@ public function input($fieldName, array $options = []) } $input = $this->_getInput($fieldName, $options); - if ($options['type'] === 'hidden') { + if ($options['type'] === 'hidden' || $options['type'] === 'submit') { if ($newTemplates) { $templater->pop(); } diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index e8517720063..1de2cf3d67b 100644 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -3120,6 +3120,24 @@ public function testInputMagicSelectChangeToRadio() $this->assertContains('input type="radio"', $result); } + /** + * testFormInputSubmit method + * + * test correct results for form::input() and type submit. + * + * @return void + */ + public function testFormInputSubmit() + { + $result = $this->Form->input('Test Submit', ['type' => 'submit', 'class' => 'foobar']); + $expected = [ + 'div' => ['class' => 'submit'], + 'input' => ['type' => 'submit', 'class' => 'foobar', 'id' => 'test-submit', 'value' => 'Test Submit'], + '/div' + ]; + $this->assertHtml($expected, $result); + } + /** * testFormInputs method *