Skip to content
Permalink
Browse files

Add possibility to use additional template variables in inputSubmit t…

…emplate.
  • Loading branch information...
Holt59 committed Jan 4, 2016
1 parent 49ea700 commit faecc1fd61cd8537f5a83d4fc5afa383a7534431
Showing with 6 additions and 3 deletions.
  1. +2 −1 src/View/Helper/FormHelper.php
  2. +4 −2 tests/TestCase/View/Helper/FormHelperTest.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', [
@@ -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',
];

0 comments on commit faecc1f

Please sign in to comment.
You can’t perform that action at this time.