@@ -588,6 +588,36 @@ public function testFormDropdownInferred(): void
588588 service ('superglobals ' )->unsetPost ('cars ' );
589589 }
590590
591+ public function testFormDropdownInferredArray (): void
592+ {
593+ $ options = [
594+ 'Swedish Cars ' => [
595+ 'volvo ' => 'Volvo ' ,
596+ 'saab ' => 'Saab ' ,
597+ ],
598+ 'German Cars ' => [
599+ 'mercedes ' => 'Mercedes ' ,
600+ 'audi ' => 'Audi ' ,
601+ ],
602+ ];
603+ $ expected = <<<EOH
604+ <select name="cars" multiple="multiple">
605+ <optgroup label="Swedish Cars">
606+ <option value="volvo" selected="selected">Volvo</option>
607+ <option value="saab">Saab</option>
608+ </optgroup>
609+ <optgroup label="German Cars">
610+ <option value="mercedes">Mercedes</option>
611+ <option value="audi" selected="selected">Audi</option>
612+ </optgroup>
613+ </select> \n
614+ EOH ;
615+ service ('superglobals ' )->setPost ('cars ' , ['volvo ' , 'audi ' ]);
616+ $ this ->assertSame ($ expected , form_dropdown ('cars ' , $ options ));
617+ $ this ->assertSame ($ expected , form_dropdown (['name ' => 'cars ' ], $ options ));
618+ service ('superglobals ' )->unsetPost ('cars ' );
619+ }
620+
591621 public function testFormDropdownWithSelectedAttribute (): void
592622 {
593623 $ expected = <<<'EOH'
@@ -684,6 +714,29 @@ public function testFormMultiselectArrayData(): void
684714 $ this ->assertSame ($ expected , form_multiselect ($ data ));
685715 }
686716
717+ public function testFormMultiselectInferred (): void
718+ {
719+ $ expected = <<<EOH
720+ <select name="shirts[]" multiple="multiple">
721+ <option value="small">Small Shirt</option>
722+ <option value="med" selected="selected">Medium Shirt</option>
723+ <option value="large" selected="selected">Large Shirt</option>
724+ <option value="xlarge">Extra Large Shirt</option>
725+ </select> \n
726+ EOH ;
727+ $ options = [
728+ 'small ' => 'Small Shirt ' ,
729+ 'med ' => 'Medium Shirt ' ,
730+ 'large ' => 'Large Shirt ' ,
731+ 'xlarge ' => 'Extra Large Shirt ' ,
732+ ];
733+
734+ service ('superglobals ' )->setPost ('shirts ' , ['med ' , 'large ' ]);
735+ $ this ->assertSame ($ expected , form_multiselect ('shirts[] ' , $ options ));
736+ $ this ->assertSame ($ expected , form_multiselect (['name ' => 'shirts[] ' , 'options ' => $ options ]));
737+ service ('superglobals ' )->unsetPost ('shirts ' );
738+ }
739+
687740 public function testFormFieldset (): void
688741 {
689742 $ expected = <<<EOH
0 commit comments