Skip to content

Commit

Permalink
Minor refactoring and removal of duplicate test.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Oct 31, 2009
1 parent 2331cfd commit 44d7742
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 22 deletions.
15 changes: 4 additions & 11 deletions cake/libs/view/helpers/form.php
Expand Up @@ -1193,7 +1193,7 @@ function submit($caption = null, $options = array()) {
$div = $options['div'];
unset($options['div']);
}
$options += array('type' => 'submit');
$options += array('type' => 'submit', 'before' => null, 'after' => null);
$divOptions = array('tag' => 'div');

if ($div === true) {
Expand All @@ -1206,16 +1206,9 @@ function submit($caption = null, $options = array()) {
$divOptions = array_merge(array('class' => 'submit', 'tag' => 'div'), $div);
}

$before = "";
$after = "";
if (isset($options['before'])) {
$before = $options['before'];
unset($options['before']);
}
if (isset($options['after'])) {
$after = $options['after'];
unset($options['after']);
}
$before = $options['before'];
$after = $options['after'];
unset($options['before'], $options['after']);

if (strpos($caption, '://') !== false) {
unset($options['type']);
Expand Down
14 changes: 3 additions & 11 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -2724,7 +2724,7 @@ function testRadio() {
**/
function testRadioHiddenInputDisabling() {
$result = $this->Form->input('Model.1.field', array(
'type' => 'radio',
'type' => 'radio',
'options' => array('option A'),
'hiddenField' => false
)
Expand Down Expand Up @@ -3370,7 +3370,7 @@ function testCheckboxHiddenDisabling() {
*/
function testCheckboxHiddenFieldOmission() {
$result = $this->Form->input('UserForm.something', array(
'type' => 'checkbox',
'type' => 'checkbox',
'hiddenField' => false
)
);
Expand Down Expand Up @@ -4652,14 +4652,6 @@ function testSubmitButton() {
);
$this->assertTags($result, $expected);

$result = $this->Form->submit('Next >', array('escape' => false));
$expected = array(
'div' => array('class' => 'submit'),
'input' => array('type' => 'submit', 'value' => 'Next >'),
'/div'
);
$this->assertTags($result, $expected);

$result = $this->Form->submit('Reset!', array('type' => 'reset'));
$expected = array(
'div' => array('class' => 'submit'),
Expand Down Expand Up @@ -4766,7 +4758,7 @@ function testSubmitImage() {
'/div'
);
$this->assertTags($result, $expected);

$result = $this->Form->submit('Not.an.image', array('before' => $before, 'after' => $after));
$expected = array(
'div' => array('class' => 'submit'),
Expand Down

0 comments on commit 44d7742

Please sign in to comment.