mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
FormHelper::submit() now accepts alternative wrapping tags, instead of a div.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7065 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
4dfe7333b7
commit
03322a31d7
2 changed files with 13 additions and 3 deletions
|
@ -1013,7 +1013,7 @@ class FormHelper extends AppHelper {
|
|||
$div = $options['div'];
|
||||
unset($options['div']);
|
||||
}
|
||||
$divOptions = array();
|
||||
$divOptions = array('tag' => 'div');
|
||||
|
||||
if ($div === true) {
|
||||
$divOptions['class'] = 'submit';
|
||||
|
@ -1022,7 +1022,7 @@ class FormHelper extends AppHelper {
|
|||
} elseif (is_string($div)) {
|
||||
$divOptions['class'] = $div;
|
||||
} elseif (is_array($div)) {
|
||||
$divOptions = array_merge(array('class' => 'submit'), $div);
|
||||
$divOptions = array_merge(array('class' => 'submit', 'tag' => 'div'), $div);
|
||||
}
|
||||
|
||||
$out = $secured;
|
||||
|
@ -1042,7 +1042,9 @@ class FormHelper extends AppHelper {
|
|||
}
|
||||
|
||||
if (isset($divOptions)) {
|
||||
$out = $this->Html->div($divOptions['class'], $out, $divOptions);
|
||||
$tag = $divOptions['tag'];
|
||||
unset($divOptions['tag']);
|
||||
$out = $this->Html->tag($tag, $out, $divOptions);
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
|
|
@ -2910,6 +2910,14 @@ class FormHelperTest extends CakeTestCase {
|
|||
);
|
||||
$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);
|
||||
|
|
Loading…
Reference in a new issue