div_box(), list_box(), button_box(), button_split_box() form()
Choices as a Bootstrap dropdown with a hidden input: div_box(), list_box() (bfh-selectbox), button_box(), button_split_box().
form()->div_box($name, $values, $extra = [], $replace = [])
form()->list_box($name, $values, $extra = [], $replace = [])
form()->button_box($name, $values, $extra = [], $replace = [])
form()->button_split_box($name, $values, $extra = [], $replace = [])Options
| Option | Meaning |
|---|---|
$values | Value => text. |
selected | Selected value; default $replace[name]. |
(html options) | See html()->div_box(). |
Example
Code
$sizes = ['s' => 'Small', 'm' => 'Medium', 'l' => 'Large'];
return form(['size' => 'm', 'size2' => 's', 'size3' => 'l', 'size4' => 'm'])
->div_box('size', $sizes)
->list_box('size2', $sizes)
->button_box('size3', $sizes)
->button_split_box('size4', $sizes);Notes
- They post through a hidden input; without JavaScript the choice cannot change. Prefer select_box() or radio_box() for forms that must work without scripts.
list_box()needs thebfh-selectasset (bootstrap-form-helpers, jQuery).
Bootstrap 3 and 5
Bootstrap 5 renders native dropdown-menu markup with data-bs-toggle (yf_html_bs5).
See also: html/div_box, form/select_box