Skip to content
This repository
Browse code

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

… Form->submit() and Form->end(). Tests added. Fixes #1569
  • Loading branch information...
commit 197c9bf912543b118094f531d96db00ac02ab7b3 1 parent e9011ba
Mark Story authored March 02, 2011
6  cake/libs/view/helpers/form.php
@@ -363,10 +363,6 @@ function end($options = null) {
363 363
 					unset($options['label']);
364 364
 				}
365 365
 				$submitOptions = $options;
366  
-
367  
-				if (!$submit) {
368  
-					$submit = __('Submit', true);
369  
-				}
370 366
 			}
371 367
 			$out .= $this->submit($submit, $submitOptions);
372 368
 		}
@@ -1309,7 +1305,7 @@ function button($title, $options = array()) {
1309 1305
  * @link http://book.cakephp.org/view/1431/submit
1310 1306
  */
1311 1307
 	function submit($caption = null, $options = array()) {
1312  
-		if (!$caption) {
  1308
+		if (!is_string($caption) && empty($caption)) {
1313 1309
 			$caption = __('Submit', true);
1314 1310
 		}
1315 1311
 		$out = null;
26  cake/tests/cases/libs/view/helpers/form.test.php
@@ -5284,6 +5284,14 @@ function testButton() {
5284 5284
  * @return void
5285 5285
  */
5286 5286
 	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
+
5287 5295
 		$result = $this->Form->submit('Test Submit');
5288 5296
 		$expected = array(
5289 5297
 			'div' => array('class' => 'submit'),
@@ -6333,6 +6341,24 @@ function testFormMagicInputLabel() {
6333 6341
 	function testFormEnd() {
6334 6342
 		$this->assertEqual($this->Form->end(), '</form>');
6335 6343
 
  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
+
6336 6362
 		$result = $this->Form->end('save');
6337 6363
 		$expected = array(
6338 6364
 			'div' => array('class' => 'submit'),

0 notes on commit 197c9bf

Please sign in to comment.
Something went wrong with that request. Please try again.