Skip to content

Commit 197c9bf

Browse files
committed
Making empty string create empty submit buttons. This applies to both Form->submit() and Form->end(). Tests added. Fixes #1569
1 parent e9011ba commit 197c9bf

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

cake/libs/view/helpers/form.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -363,10 +363,6 @@ function end($options = null) {
363363
unset($options['label']);
364364
}
365365
$submitOptions = $options;
366-
367-
if (!$submit) {
368-
$submit = __('Submit', true);
369-
}
370366
}
371367
$out .= $this->submit($submit, $submitOptions);
372368
}
@@ -1309,7 +1305,7 @@ function button($title, $options = array()) {
13091305
* @link http://book.cakephp.org/view/1431/submit
13101306
*/
13111307
function submit($caption = null, $options = array()) {
1312-
if (!$caption) {
1308+
if (!is_string($caption) && empty($caption)) {
13131309
$caption = __('Submit', true);
13141310
}
13151311
$out = null;

cake/tests/cases/libs/view/helpers/form.test.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5284,6 +5284,14 @@ function testButton() {
52845284
* @return void
52855285
*/
52865286
function testSubmitButton() {
5287+
$result = $this->Form->submit('');
5288+
$expected = array(
5289+
'div' => array('class' => 'submit'),
5290+
'input' => array('type' => 'submit', 'value' => ''),
5291+
'/div'
5292+
);
5293+
$this->assertTags($result, $expected);
5294+
52875295
$result = $this->Form->submit('Test Submit');
52885296
$expected = array(
52895297
'div' => array('class' => 'submit'),
@@ -6333,6 +6341,24 @@ function testFormMagicInputLabel() {
63336341
function testFormEnd() {
63346342
$this->assertEqual($this->Form->end(), '</form>');
63356343

6344+
$result = $this->Form->end('');
6345+
$expected = array(
6346+
'div' => array('class' => 'submit'),
6347+
'input' => array('type' => 'submit', 'value' => ''),
6348+
'/div',
6349+
'/form'
6350+
);
6351+
$this->assertTags($result, $expected);
6352+
6353+
$result = $this->Form->end(array('label' => ''));
6354+
$expected = array(
6355+
'div' => array('class' => 'submit'),
6356+
'input' => array('type' => 'submit', 'value' => ''),
6357+
'/div',
6358+
'/form'
6359+
);
6360+
$this->assertTags($result, $expected);
6361+
63366362
$result = $this->Form->end('save');
63376363
$expected = array(
63386364
'div' => array('class' => 'submit'),

0 commit comments

Comments
 (0)