Browse Source

Add possibility to use additional template variables in inputSubmit template.

mcapelle 10 years ago
parent
commit
faecc1fd61
2 changed files with 6 additions and 3 deletions
  1. 2 1
      src/View/Helper/FormHelper.php
  2. 4 2
      tests/TestCase/View/Helper/FormHelperTest.php

+ 2 - 1
src/View/Helper/FormHelper.php

@@ -1769,7 +1769,8 @@ class FormHelper extends Helper
 
         $input = $this->formatTemplate('inputSubmit', [
             'type' => $type,
-            'attrs' => $this->templater()->formatAttributes($options)
+            'attrs' => $this->templater()->formatAttributes($options),
+            'templateVars' => $options['templateVars']
         ]);
 
         return $this->formatTemplate('submitContainer', [

+ 4 - 2
tests/TestCase/View/Helper/FormHelperTest.php

@@ -583,23 +583,25 @@ class FormHelperTest extends TestCase
     }
     
     /**
-     * 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',
         ];