InputfieldFloat
Floating point number input
Extends [[InputfieldInteger]] — all integer properties
(inputType, min, max, size, placeholder, initValue, defaultValue, range
validation, empty-vs-zero behavior, etc.) are inherited and documented there.
$f = $modules->get('InputfieldFloat');
$f->name = 'price';
$f->label = 'Price';
$f->precision = 2;
$f->min = 0;
$form->add($f); See [[Inputfield]] for the shared Inputfield API.
| Property | Type | Default | Description |
|---|---|---|---|
precision | int\|null | 2 | Decimal places to round to; -1 or null disables rounding 3.0.193+ |
digits | int | 0 | Total significant digits for fixed-decimal (MySQL DECIMAL) mode |
noE | bool | false | Convert scientific notation (1.23E-4) to a plain decimal in the input 3.0.193+ |
step | int\|string | 'any' | HTML5 step; defaults to 'any' (allows any decimal); only applies when inputType = 'number' |
precision controls how many decimal places the value is rounded to when set:
$f->precision = 2; // 3.14159 → 3.14 (default)
$f->precision = 0; // 3.14 → 3 (integer-like, but float type)
$f->precision = -1; // no rounding applied 3.0.193+When inputType = 'number' and step is 'any', the step attribute is automatically
derived from precision at render time (e.g. precision = 2 → step = ".01").
Some locales or data sources produce values in scientific notation (1.5E-3). By
default these are passed through as-is. Set noE = true to convert them to plain
decimals in the rendered <input>:
$f->noE = true; // 1.5E-3 → 0.0015 in the input elementWhen inputType = 'number', the value is converted to use . as the decimal
separator regardless of locale, because the HTML5 number input requires it.
For inputType = 'text', locale-specific separators are preserved.
isEmpty()(inherited from [[InputfieldInteger]]) returnstrueonly for empty string — the float0.0is a present, non-empty value.- Source file:
wire/modules/Inputfield/InputfieldFloat/Inputfield Float.module
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: InputfieldInteger, Inputfield, WireData and Wire.
Common
| Name | Return | Summary | |
|---|---|---|---|
Inputfield Inputfield Inputfield | string | Override method from Inputfield to convert locale specific decimals for input[type=number] | |
Inputfield Inputfield Inputfield | InputfieldWrapper | Inputfield config | |
Inputfield Inputfield Inputfield | bool | Does the value have an E in it like ”123E-3” or "123E3” ? |
Properties
| Name | Return | Summary | |
|---|---|---|---|
| Inputfield | int float string | Initial/default value (when used with FieldtypeInteger) | |
| Inputfield | int | Total digits, for when used in decimal mode DEFAULT: 0 | |
| Inputfield | int float | Initial/default value (when used as independent Inputfield) | |
| Inputfield | string | Input type to use, one of "text" or "number" DEFAULT: text | |
| Inputfield | int float | Maximum allowed value | |
| Inputfield | int float | Minimum allowed value | |
| Inputfield | bool int | Convert “123E-3” and “123E3” type numbers to real numbers in the <input>? 3.0.193+ DEFAULT: false | |
| Inputfield | string | Placeholder attribute for input DEFAULT: '' | |
| Inputfield | int null string | Decimals precision (or -1 to disable rounding in 3.0.193+ DEFAULT: 2 | |
| Inputfield | int | Size attribute for input | |
| Inputfield | int float string | HTML5 step attibute value DEFAULT: any |
Additional methods and properties
In addition to the methods and properties above, Inputfield
API reference based on ProcessWire core version 3.0.267