Browse Source

Consolidate single HTML tags to have a closing /> tag element.

Mark Scherer 10 years ago
parent
commit
94adbbaf08
2 changed files with 8 additions and 8 deletions
  1. 2 2
      src/View/Helper/FormHelper.php
  2. 6 6
      tests/TestCase/View/Helper/FormHelperTest.php

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

@@ -105,8 +105,8 @@ class FormHelper extends Helper
             'formEnd' => '</form>',
             'formGroup' => '{{label}}{{input}}',
             'hiddenBlock' => '<div style="display:none;">{{content}}</div>',
-            'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}>',
-            'inputSubmit' => '<input type="{{type}}"{{attrs}}>',
+            'input' => '<input type="{{type}}" name="{{name}}"{{attrs}}/>',
+            'inputSubmit' => '<input type="{{type}}"{{attrs}}/>',
             'inputContainer' => '<div class="input {{type}}{{required}}">{{content}}</div>',
             'inputContainerError' => '<div class="input {{type}}{{required}} error">{{content}}{{error}}</div>',
             'label' => '<label{{attrs}}>{{text}}</label>',

+ 6 - 6
tests/TestCase/View/Helper/FormHelperTest.php

@@ -556,7 +556,7 @@ class FormHelperTest extends TestCase
     {
         $result = $this->Form->input('text', [
             'templates' => [
-                'input' => '<input custom="{{forinput}}" type="{{type}}" name="{{name}}"{{attrs}}>',
+                'input' => '<input custom="{{forinput}}" type="{{type}}" name="{{name}}"{{attrs}}/>',
                 'label' => '<label{{attrs}}>{{text}} {{forlabel}}</label>',
                 'formGroup' => '{{label}}{{forgroup}}{{input}}',
                 'inputContainer' => '<div class="input {{type}}{{required}}">{{content}}{{forcontainer}}</div>',
@@ -917,7 +917,7 @@ class FormHelperTest extends TestCase
             'name' => 'password', 'type' => 'password'
         ]];
         $this->assertHtml($expected, $result);
-        $this->assertNotRegExp('/<input[^<>]+[^id|name|type|value]=[^<>]*>$/', $result);
+        $this->assertNotRegExp('/<input[^<>]+[^id|name|type|value]=[^<>]*\/>$/', $result);
 
         $result = $this->Form->text('user_form');
         $expected = ['input' => [
@@ -3534,7 +3534,7 @@ class FormHelperTest extends TestCase
             'label' => '<label{{attrs}}>{{input}}{{text}}</label>',
         ]);
         $result = $this->Form->label('Person.accept_terms', 'Accept', [
-            'input' => '<input type="checkbox" name="accept_tos" >'
+            'input' => '<input type="checkbox" name="accept_tos"/>'
         ]);
         $expected = [
             'label' => ['for' => 'person-accept-terms'],
@@ -7338,11 +7338,11 @@ class FormHelperTest extends TestCase
      */
     public function testResetTemplates()
     {
-        $this->Form->templates(['input' => '<input>']);
-        $this->assertEquals('<input>', $this->Form->templater()->get('input'));
+        $this->Form->templates(['input' => '<input/>']);
+        $this->assertEquals('<input/>', $this->Form->templater()->get('input'));
 
         $this->assertNull($this->Form->resetTemplates());
-        $this->assertNotEquals('<input>', $this->Form->templater()->get('input'));
+        $this->assertNotEquals('<input/>', $this->Form->templater()->get('input'));
     }
 
     /**