Skip to content

Commit

Permalink
Making empty string create empty submit buttons. This applies to both…
Browse files Browse the repository at this point in the history
… Form->submit() and Form->end(). Tests added. Fixes #1569
  • Loading branch information
markstory committed Mar 3, 2011
1 parent e9011ba commit 197c9bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
6 changes: 1 addition & 5 deletions cake/libs/view/helpers/form.php
Expand Up @@ -363,10 +363,6 @@ function end($options = null) {
unset($options['label']);
}
$submitOptions = $options;

if (!$submit) {
$submit = __('Submit', true);
}
}
$out .= $this->submit($submit, $submitOptions);
}
Expand Down Expand Up @@ -1309,7 +1305,7 @@ function button($title, $options = array()) {
* @link http://book.cakephp.org/view/1431/submit
*/
function submit($caption = null, $options = array()) {
if (!$caption) {
if (!is_string($caption) && empty($caption)) {
$caption = __('Submit', true);
}
$out = null;
Expand Down
26 changes: 26 additions & 0 deletions cake/tests/cases/libs/view/helpers/form.test.php
Expand Up @@ -5284,6 +5284,14 @@ function testButton() {
* @return void
*/
function testSubmitButton() {
$result = $this->Form->submit('');
$expected = array(
'div' => array('class' => 'submit'),
'input' => array('type' => 'submit', 'value' => ''),
'/div'
);
$this->assertTags($result, $expected);

$result = $this->Form->submit('Test Submit');
$expected = array(
'div' => array('class' => 'submit'),
Expand Down Expand Up @@ -6333,6 +6341,24 @@ function testFormMagicInputLabel() {
function testFormEnd() {
$this->assertEqual($this->Form->end(), '</form>');

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

$result = $this->Form->end(array('label' => ''));
$expected = array(
'div' => array('class' => 'submit'),
'input' => array('type' => 'submit', 'value' => ''),
'/div',
'/form'
);
$this->assertTags($result, $expected);

$result = $this->Form->end('save');
$expected = array(
'div' => array('class' => 'submit'),
Expand Down

0 comments on commit 197c9bf

Please sign in to comment.