InputfieldIcon
Font Awesome icon picker
Renders a searchable <select> where users choose an
icon from the active admin icon set. The stored value is a Font Awesome class
name such as fa-star.
$f = $modules->get('InputfieldIcon');
$f->name = 'feature_icon';
$f->label = 'Feature icon';
$f->value = 'fa-bolt';
$form->add($f); For shared Inputfield behavior, including labels, attributes, rendering, processing, and validation, see Inputfield.
Expand all Collapse all API reference
| Property | Type | Default | Description |
|---|---|---|---|
prefixValue | bool | true | Whether value / val() return values include the fa- prefix. |
The inherited icon property controls the icon shown in the inputfield header.
When a selected value is rendered, Inputfield updates this header icon to
match the selected icon.
| Constant | Value | Description |
|---|---|---|
Inputfield | 'fa-' | Font Awesome class prefix. |
Set values with or without the fa- prefix:
$f->value = 'star';
echo $f->value; // fa-star
$f->value = 'fa-bolt';
echo $f->value; // fa-boltInvalid icon names are cleared:
$f->value = 'not-an-icon';
echo $f->value; // ''Set prefixValue to false when you want reads without the prefix:
$f->value = 'fa-user';
$f->prefixValue = false;
echo $f->value; // user
echo $f->val(); // userInternally, assigned values are accepted only when they exist in the active icon list.
render()
Render the icon picker:
echo $f->render();The rendered output includes:
- A
<select>with all available icon options. - A search input for filtering icons in the browser.
- A hidden
.Inputfieldcontainer populated by JavaScript with clickable icon tiles.IconAll
When the field is not required, an empty <option> is included so the selected
icon can be cleared. Required fields omit that empty option.
The icon list is chosen automatically from $config->adminIcons['version']:
- Font Awesome 6 or newer uses
icons6.inc. - Older admin icon sets use
icons.inc.
This is an internal detail detected during init() so the picker matches the
active admin theme.
Inputfield uses inherited Inputfield input processing. Submitted values
are simple strings and still pass through the same value normalization as API
assignments.
$form->processInput($input->post);
$icon = $f->val(); // e.g. fa-star- Get an instance with
$modules->get('Inputfield.Icon') - The JavaScript behavior lives in
Inputfield.Icon.js - Styling lives in
Inputfield.Icon.css - Icon list files are
icons.incandicons6.inc. - Unknown/custom icon class names are not preserved unless they exist in the bundled list for the active icon set.
- Source file:
wire/modules/Inputfield/Inputfield.Icon/Inputfield Icon.module
API reference: methods, properties, hooks
Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the Inputfield class also inherits all the methods and properties of: Inputfield, WireData and Wire.
Common
| Name | Return | Summary | |
|---|---|---|---|
Inputfield Inputfield Inputfield | bool mixed null string | Get attribute | |
Inputfield Inputfield Inputfield | string | Render | |
Inputfield Inputfield Inputfield | Inputfield | Set attribute |
Properties
| Name | Return | Summary | |
|---|---|---|---|
| Inputfield | bool | Should value attribute always start with prefix? DEFAULT: true |
Additional methods and properties
In addition to the methods and properties above, Inputfield
API reference based on ProcessWire core version 3.0.269