From 197c9bf912543b118094f531d96db00ac02ab7b3 Mon Sep 17 00:00:00 2001 From: mark_story Date: Wed, 2 Mar 2011 20:27:02 -0500 Subject: [PATCH] Making empty string create empty submit buttons. This applies to both Form->submit() and Form->end(). Tests added. Fixes #1569 --- cake/libs/view/helpers/form.php | 6 +---- .../cases/libs/view/helpers/form.test.php | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/cake/libs/view/helpers/form.php b/cake/libs/view/helpers/form.php index 7b6dd35a5a4..84bc7a2e208 100644 --- a/cake/libs/view/helpers/form.php +++ b/cake/libs/view/helpers/form.php @@ -363,10 +363,6 @@ function end($options = null) { unset($options['label']); } $submitOptions = $options; - - if (!$submit) { - $submit = __('Submit', true); - } } $out .= $this->submit($submit, $submitOptions); } @@ -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; diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 3aea5e66595..8816fe816f8 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -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'), @@ -6333,6 +6341,24 @@ function testFormMagicInputLabel() { function testFormEnd() { $this->assertEqual($this->Form->end(), ''); + $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'),