Number

Numeric input with support for integers, decimals and min/max ranges.

Number fields collect numeric values with built-in validation for ranges, steps and decimal precision. They include spinner controls and only accept numeric input.

Basic Usage

Add a number field using the addNumber() builder method:

app/Models/Survey.php

Available Settings

SettingTypeDescription
minnumericMinimum allowed value
maxnumericMaximum allowed value
stepnumericIncrement/decrement step value (default: 1)
decimal_placesintegerNumber of decimal places to allow (default: 0)

Working with Decimals

Use the decimalPlaces() method to control decimal precision:

Validation

Number fields are validated by the NumericFieldValidator, which checks:

  • Value must be numeric
  • Value must be within min/max range (if set)
  • Value must match decimal_places precision
  • Value must be a multiple of step (if set)

Frontend Behavior

  • Shows numeric keyboard on mobile devices
  • Increment/decrement buttons (up/down arrows) on desktop
  • Prevents non-numeric characters (except decimal point when allowed)
  • Arrow up/down keys adjust value by step amount
  • Formats decimal places on blur
  • Shows validation errors inline

Common Use Cases

Integers

Age, quantity, count, year

decimalPlaces(0)

Money

Prices, salaries, costs

decimalPlaces(2), step(0.01)

Percentages

Rates, completion, scores

min(0), max(100), decimalPlaces(1)

Measurements

Height, weight, distance

decimalPlaces(1), step(0.1)