Browse Source

Remove the div option from submit().

Templates should be used instead.
mark_story 12 years ago
parent
commit
35e01a131f
2 changed files with 6 additions and 43 deletions
  1. 6 31
      src/View/Helper/FormHelper.php
  2. 0 12
      tests/TestCase/View/Helper/FormHelperTest.php

+ 6 - 31
src/View/Helper/FormHelper.php

@@ -157,7 +157,8 @@ class FormHelper extends Helper {
 		'formGroup' => '{{label}}{{input}}',
 		'checkboxFormGroup' => '{{input}}{{label}}',
 		'groupContainer' => '<div class="input {{type}}{{required}}">{{content}}</div>',
-		'groupContainerError' => '<div class="input {{type}}{{required}} error">{{content}}{{error}}</div>'
+		'groupContainerError' => '<div class="input {{type}}{{required}} error">{{content}}{{error}}</div>',
+		'submitContainer' => '<div class="submit">{{content}}</div>',
 	];
 
 /**
@@ -1466,12 +1467,6 @@ class FormHelper extends Helper {
  * - `type` - Set to 'reset' for reset inputs. Defaults to 'submit'
  * - Other attributes will be assigned to the input element.
  *
- * ### Options
- *
- * - `div` - Include a wrapping div?  Defaults to true. Accepts sub options similar to
- *   FormHelper::input().
- * - Other attributes will be assigned to the input element.
- *
  * @param string $caption The label appearing on the button OR if string contains :// or the
  *  extension .jpg, .jpe, .jpeg, .gif, .png use an image if the extension
  *  exists, AND the first character is /, image is relative to webroot,
@@ -1484,24 +1479,7 @@ class FormHelper extends Helper {
 		if (!is_string($caption) && empty($caption)) {
 			$caption = __d('cake', 'Submit');
 		}
-		$div = true;
-
-		if (isset($options['div'])) {
-			$div = $options['div'];
-			unset($options['div']);
-		}
-		$options += array('type' => 'submit', 'before' => null, 'after' => null, 'secure' => false);
-		$divOptions = array('tag' => 'div');
-
-		if ($div === true) {
-			$divOptions['class'] = 'submit';
-		} elseif ($div === false) {
-			unset($divOptions);
-		} elseif (is_string($div)) {
-			$divOptions['class'] = $div;
-		} elseif (is_array($div)) {
-			$divOptions = array_merge(array('class' => 'submit', 'tag' => 'div'), $div);
-		}
+		$options += array('type' => 'submit', 'secure' => false);
 
 		if (isset($options['name'])) {
 			$this->_secure($options['secure'], $this->_secureFieldName($options));
@@ -1541,12 +1519,9 @@ class FormHelper extends Helper {
 		}
 		$out = $tag;
 
-		if (isset($divOptions)) {
-			$tag = $divOptions['tag'];
-			unset($divOptions['tag']);
-			$out = $this->Html->tag($tag, $out, $divOptions);
-		}
-		return $out;
+		return $this->formatTemplate('submitContainer', [
+			'content' => $tag
+		]);
 	}
 
 /**

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

@@ -5241,18 +5241,6 @@ class FormHelperTest extends TestCase {
 		);
 		$this->assertTags($result, $expected);
 
-		$result = $this->Form->submit('Test Submit', array('div' => array('tag' => 'span')));
-		$expected = array(
-			'span' => array('class' => 'submit'),
-			'input' => array('type' => 'submit', 'value' => 'Test Submit'),
-			'/span'
-		);
-		$this->assertTags($result, $expected);
-
-		$result = $this->Form->submit('Test Submit', array('class' => 'save', 'div' => false));
-		$expected = array('input' => array('type' => 'submit', 'value' => 'Test Submit', 'class' => 'save'));
-		$this->assertTags($result, $expected);
-
 		$result = $this->Form->submit('Next >');
 		$expected = array(
 			'div' => array('class' => 'submit'),