Number
Integer input - digits with an optional leading minus. It collects an int.
$p->number('weight', 'Basket weight (g)')
->min(200) // Lowest accepted value, inclusive.
->max(9000) // Highest accepted value, inclusive.
->step(100) // Amount the Up/Down keys adjust by.
->default(1200); // Initial value.
Runnable script: playground/02-widgets-number.php.
Options
| Name | Description | Required | Default |
|---|---|---|---|
min() | Lowest accepted value, inclusive. | No | Unbounded |
max() | Highest accepted value, inclusive. | No | Unbounded |
step() | Amount the Up/Down keys adjust by; must be positive. | No | 1 |
default() | Initial value. | No | 0 |
With no bounds declared, the field is a plain integer entry and the arrow keys are inert. Declare min(), max() or step() and Up/Down adjustment turns on; the value is clamped only when a range (min() / max()) is set.
Keyboard
| Key | Action |
|---|---|
| digits | Insert a digit |
| - | Leading minus (once, at the start) |
| ← / → | Move the caret |
| ↑ / ↓ | Increment / decrement by step (only when bounds are set) |
| Enter | Accept (an out-of-range value is rejected inline) |
| Esc | Cancel |
Headless behavior
The bounds are enforced when the form runs headlessly too - a value outside the range is rejected - and they surface in the JSON schema as min, max and step on the prompt.
Display modes
In all four display modes - Unicode or ASCII, color on or off:
| ANSI | No ANSI | |
| Unicode | ||
| ASCII |