Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Remove the div option from submit().

Templates should be used instead.
  • Loading branch information...
commit 35e01a131f558af6573e3001b8b5289ead11ecfc 1 parent 444699e
@markstory markstory authored
View
37 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 @@ public function postLink($title, $url = null, $options = array(), $confirmMessag
* - `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 @@ public function submit($caption = null, $options = array()) {
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 @@ public function submit($caption = null, $options = array()) {
}
$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
+ ]);
}
/**
View
12 tests/TestCase/View/Helper/FormHelperTest.php
@@ -5241,18 +5241,6 @@ public function testSubmitButton() {
);
$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'),
Please sign in to comment.
Something went wrong with that request. Please try again.