image_select_box() form()

Pick one image from a list of thumbnails (jQuery image picker); posts the value of the picked image.

form()->image_select_box($name, $values, $extra = [], $replace = [])

Options

OptionMeaning
$valuesValue => image URL.
selectedPicked value.

Example

Code

$swatch = fn ($color) => 'data:image/svg+xml,' . rawurlencode('<svg xmlns="http://www.w3.org/2000/svg" width="60" height="40"><rect width="60" height="40" fill="' . $color . '"/></svg>');
return form(['theme' => 'blue'])
    ->image_select_box('theme', ['blue' => $swatch('#337ab7'), 'green' => $swatch('#5cb85c'), 'orange' => $swatch('#f0ad4e')]);

Notes

  • Needs jQuery and the jquery-image-picker asset, loaded by the field.

See also: html/image_select_box, demo:form/jquery_image_picker