Skip to content
Permalink
Browse files

Making empty string create empty submit buttons. This applies to both…

… Form->submit() and Form->end(). Tests added. Fixes #1569
  • Loading branch information...
markstory committed Mar 3, 2011
1 parent e9011ba commit 197c9bf912543b118094f531d96db00ac02ab7b3
Showing with 27 additions and 5 deletions.
  1. +1 −5 cake/libs/view/helpers/form.php
  2. +26 −0 cake/tests/cases/libs/view/helpers/form.test.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;
@@ -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(), '</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'),

0 comments on commit 197c9bf

Please sign in to comment.
You can’t perform that action at this time.