Skip to content

Commit

Permalink
Add possibility to use additional template variables in inputSubmit t…
Browse files Browse the repository at this point in the history
…emplate.
  • Loading branch information
Holt59 committed Jan 4, 2016
1 parent 49ea700 commit faecc1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/View/Helper/FormHelper.php
Expand Up @@ -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', [
Expand Down
6 changes: 4 additions & 2 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -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' => '<input custom="{{forinput}}" type="{{type}}"{{attrs}}/>',
'submitContainer' => '<div class="submit">{{content}}{{forcontainer}}</div>'
]);
$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',
];
Expand Down

0 comments on commit faecc1f

Please sign in to comment.