Summary
Interactive rating input for scores, feedback, and reviews. Supports custom icons (stars, hearts, etc.), semantic colors, and various sizes. Includes a read-only mode that supports fractional values (e.g., 3.7) with partial icon fill.
Shares its icon rendering and fractional fill logic with RatingColumn. The field uses
icon(), color() and size(); the column uses ratingIcon(), ratingColor() and ratingSize().
Basic usage
Standard 5-star rating
Custom icon and color
Read-only fractional display
State & validation
Stored value
In interactive mode, the state is an integer representing the number of selected items. In read-only mode, it can be a float.Validation rules (built-in)
Validation, interaction and storage
Submitted values must be finite numbers within0..max(). Interactive ratings must be whole numbers. Arrays, booleans, nested data, malformed strings and nonfinite values are rejected. Numeric strings are normalized to integer values in interactive mode and floats in read-only mode. Empty optional values remain null; add required() to require a value.
Zero is a valid saved rating, although clicking icons selects values from 1 through max(). If at least one star is mandatory, add rules(['min:1']) as well as required().
->readOnly()->dehydrated(false) and calculate the average in your application. Disabled fields are normally excluded from saved form data.
integer cast for selected ratings and a float cast for averages. In a custom form, obtain validated data with $this->form->getState() before saving it.
Tab focuses the selected rating, or the first icon when empty. Arrow keys select adjacent values; horizontal direction follows RTL. Home/End select the first/last value. Space and Enter select the focused icon. Hover changes the preview without saving; leaving, cancelling a pointer or receiving external state restores the saved preview. Disabled and read-only ratings cannot be changed through these controls.
The field emits bubbling browser input and change events with event.detail.value after a changed selection. Use live() with afterStateUpdated() for server-side change callbacks. Default binding defers state until the next form request. Selecting the current value again does not clear it.
Fractional read-only ratings and table columns load shared styles only. Interactive fields load their JS on activation. They use no continuous animation loop or resize observer; icons adapt to layout changes through CSS.
Configuration API
All methods acceptClosure unless noted.
Public helper methods
Real-world examples
Feedback form with required rating
Product list with average rating
Playground
/admin/flex-fields/rating
See Playground for setup.