diff --git a/src/View/Helper/FormHelper.php b/src/View/Helper/FormHelper.php index c02d3dcebad..8f90596abb9 100644 --- a/src/View/Helper/FormHelper.php +++ b/src/View/Helper/FormHelper.php @@ -1769,7 +1769,8 @@ public function submit($caption = null, array $options = []) $input = $this->formatTemplate('inputSubmit', [ 'type' => $type, - 'attrs' => $this->templater()->formatAttributes($options) + 'attrs' => $this->templater()->formatAttributes($options), + 'templateVars' => $options['templateVars'] ]); return $this->formatTemplate('submitContainer', [ diff --git a/tests/TestCase/View/Helper/FormHelperTest.php b/tests/TestCase/View/Helper/FormHelperTest.php index 944fccc5071..b44e43b6246 100644 --- a/tests/TestCase/View/Helper/FormHelperTest.php +++ b/tests/TestCase/View/Helper/FormHelperTest.php @@ -583,23 +583,25 @@ public function testInputTemplateVars() } /** - * Test using template vars in submitContainer template. + * Test using template vars in inputSubmit and submitContainer template. * * @return void */ public function testSubmitTemplateVars() { $this->Form->templates([ + 'inputSubmit' => '', 'submitContainer' => '
{{content}}{{forcontainer}}
' ]); $result = $this->Form->submit('Submit', [ 'templateVars' => [ + 'forinput' => 'in-input', 'forcontainer' => 'in-container' ] ]); $expected = [ 'div' => ['class'], - 'input' => ['type' => 'submit', 'value' => 'Submit'], + 'input' => ['custom' => 'in-input', 'type' => 'submit', 'value' => 'Submit'], 'in-container', '/div', ];