@@ -3448,7 +3448,10 @@ function testSelectMultipleCheckboxSecurity() {
3448
3448
* @return void
3449
3449
*/
3450
3450
function testInputMultipleCheckboxes () {
3451
- $ result = $ this ->Form ->input ('Model.multi_field ' , array ('options ' => array ('first ' , 'second ' , 'third ' ), 'multiple ' => 'checkbox ' ));
3451
+ $ result = $ this ->Form ->input ('Model.multi_field ' , array (
3452
+ 'options ' => array ('first ' , 'second ' , 'third ' ),
3453
+ 'multiple ' => 'checkbox '
3454
+ ));
3452
3455
$ expected = array (
3453
3456
array ('div ' => array ('class ' => 'input select ' )),
3454
3457
array ('label ' => array ('for ' => 'ModelMultiField ' )),
@@ -3477,7 +3480,10 @@ function testInputMultipleCheckboxes() {
3477
3480
);
3478
3481
$ this ->assertTags ($ result , $ expected );
3479
3482
3480
- $ result = $ this ->Form ->input ('Model.multi_field ' , array ('options ' => array ('a ' => 'first ' , 'b ' => 'second ' , 'c ' => 'third ' ), 'multiple ' => 'checkbox ' ));
3483
+ $ result = $ this ->Form ->input ('Model.multi_field ' , array (
3484
+ 'options ' => array ('a ' => 'first ' , 'b ' => 'second ' , 'c ' => 'third ' ),
3485
+ 'multiple ' => 'checkbox '
3486
+ ));
3481
3487
$ expected = array (
3482
3488
array ('div ' => array ('class ' => 'input select ' )),
3483
3489
array ('label ' => array ('for ' => 'ModelMultiField ' )),
@@ -3506,7 +3512,12 @@ function testInputMultipleCheckboxes() {
3506
3512
);
3507
3513
$ this ->assertTags ($ result , $ expected );
3508
3514
3509
- $ result = $ this ->Form ->input ('Model.multi_field ' , array ('options ' => array ('1 ' => 'first ' ), 'multiple ' => 'checkbox ' , 'label ' => false , 'div ' => false ));
3515
+ $ result = $ this ->Form ->input ('Model.multi_field ' , array (
3516
+ 'options ' => array ('1 ' => 'first ' ),
3517
+ 'multiple ' => 'checkbox ' ,
3518
+ 'label ' => false ,
3519
+ 'div ' => false
3520
+ ));
3510
3521
$ expected = array (
3511
3522
'input ' => array ('type ' => 'hidden ' , 'name ' => 'data[Model][multi_field] ' , 'value ' => '' , 'id ' => 'ModelMultiField ' ),
3512
3523
array ('div ' => array ('class ' => 'checkbox ' )),
@@ -3518,7 +3529,12 @@ function testInputMultipleCheckboxes() {
3518
3529
);
3519
3530
$ this ->assertTags ($ result , $ expected );
3520
3531
3521
- $ result = $ this ->Form ->input ('Model.multi_field ' , array ('options ' => array ('2 ' => 'second ' ), 'multiple ' => 'checkbox ' , 'label ' => false , 'div ' => false ));
3532
+ $ result = $ this ->Form ->input ('Model.multi_field ' , array (
3533
+ 'options ' => array ('2 ' => 'second ' ),
3534
+ 'multiple ' => 'checkbox ' ,
3535
+ 'label ' => false ,
3536
+ 'div ' => false
3537
+ ));
3522
3538
$ expected = array (
3523
3539
'input ' => array ('type ' => 'hidden ' , 'name ' => 'data[Model][multi_field] ' , 'value ' => '' , 'id ' => 'ModelMultiField ' ),
3524
3540
array ('div ' => array ('class ' => 'checkbox ' )),
@@ -3531,6 +3547,34 @@ function testInputMultipleCheckboxes() {
3531
3547
$ this ->assertTags ($ result , $ expected );
3532
3548
}
3533
3549
3550
+ /**
3551
+ * test that select() with multiple = checkbox works with overriding name attribute.
3552
+ *
3553
+ * @return void
3554
+ */
3555
+ function testSelectCheckboxMultipleOverrideName () {
3556
+ $ result = $ this ->Form ->input ('category ' , array (
3557
+ 'type ' => 'select ' ,
3558
+ 'multiple ' => 'checkbox ' ,
3559
+ 'name ' => 'data[fish] ' ,
3560
+ 'options ' => array ('1 ' , '2 ' ),
3561
+ 'div ' => false ,
3562
+ 'label ' => false ,
3563
+ ));
3564
+ $ expected = array (
3565
+ 'input ' => array ('type ' => 'hidden ' , 'name ' => 'data[fish] ' , 'value ' => '' , 'id ' => 'category ' ),
3566
+ array ('div ' => array ('class ' => 'checkbox ' )),
3567
+ array ('input ' => array ('type ' => 'checkbox ' , 'name ' => 'data[fish][] ' , 'value ' => '0 ' , 'id ' => 'Category0 ' )),
3568
+ array ('label ' => array ('for ' => 'Category0 ' )), '1 ' , '/label ' ,
3569
+ '/div ' ,
3570
+ array ('div ' => array ('class ' => 'checkbox ' )),
3571
+ array ('input ' => array ('type ' => 'checkbox ' , 'name ' => 'data[fish][] ' , 'value ' => '1 ' , 'id ' => 'Category1 ' )),
3572
+ array ('label ' => array ('for ' => 'Category1 ' )), '2 ' , '/label ' ,
3573
+ '/div '
3574
+ );
3575
+ $ this ->assertTags ($ result , $ expected );
3576
+ }
3577
+
3534
3578
/**
3535
3579
* testCheckbox method
3536
3580
*
0 commit comments