Browse Source

Merge pull request #6382 from cakephp/hotfix-input-submit

Fix input submit via magic input method.
Mark Story 11 years ago
parent
commit
8a83521c46
2 changed files with 20 additions and 1 deletions
  1. 2 1
      src/View/Helper/FormHelper.php
  2. 18 0
      tests/TestCase/View/Helper/FormHelperTest.php

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

@@ -1012,6 +1012,7 @@ class FormHelper extends Helper
 
         $label = $options['label'];
         unset($options['label']);
+
         $nestedInput = false;
         if ($options['type'] === 'checkbox') {
             $nestedInput = true;
@@ -1023,7 +1024,7 @@ class FormHelper extends Helper
         }
 
         $input = $this->_getInput($fieldName, $options);
-        if ($options['type'] === 'hidden') {
+        if ($options['type'] === 'hidden' || $options['type'] === 'submit') {
             if ($newTemplates) {
                 $templater->pop();
             }

+ 18 - 0
tests/TestCase/View/Helper/FormHelperTest.php

@@ -3121,6 +3121,24 @@ class FormHelperTest extends TestCase
     }
 
     /**
+     * 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
      *
      * test correct results from form::inputs().