You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e2b62bd
Browse filesBrowse the repository at this point in the historyBrowse files
If the array passed as `$options` is a multidimensional array, then `form_dropdown()` will produce an <optgroup> with the array key as the label.
463
463
464
+
##### Automatic Selection from POST
465
+
466
+
If no value is passed to `$selected` (or if it is an empty array), `form_dropdown()` and `form_multiselect()` will attempt to infer the selected option(s) directly from the current request's `$_POST` data using the field name (trailing `[]` brackets are automatically stripped).
467
+
468
+
!!! note "Note"
469
+
This fallback only inspects `$_POST` from the current request. It does not restore old input after a redirect with `redirect()->withInput()`. To restore submitted values after a redirect, pass `set_value()` or `old()` to `$selected` explicitly.
@@ -475,7 +482,25 @@ If the array passed as `$options` is a multidimensional array, then `form_dropdo
475
482
476
483
Lets you create a standard multiselect field. The first parameter will contain the name of the field, the second parameter will contain an associative array of options, and the third parameter will contain the value or values you wish to be selected.
477
484
478
-
The parameter usage is identical to using `form_dropdown()` above, except, of course, that the name of the field will need to use POST array syntax, e.g., foo[].
485
+
The parameter usage is identical to using `form_dropdown()` above, except, of course, that the name of the field will need to use POST array syntax, e.g., `shirts[]`.
486
+
487
+
If `$selected` is omitted, selections are automatically inferred from `$_POST['shirts']`:
488
+
489
+
```php
490
+
<?php
491
+
492
+
// If $_POST['shirts'] contains ['small', 'large']:
0 commit comments