stars(), stars_select() form()
A rating: stars() shows the value as stars, stars_select() lets the visitor pick one with radio stars.
form()->stars($name = '', $desc = '', $extra = [], $replace = [])
form()->stars_select($name = '', $desc = '', $extra = [], $replace = [])Options
| Option | Meaning |
|---|---|
stars, max | Number of stars (5); value of a full row (5). |
color_ok, color_ko, class, class_ok, class_ko | Colours and classes of lit and dim stars (stars()). |
value, selected | stars_select() with yf_form2_stars::$SELECT_FIX: the start value (else $replace[name], then the filter). |
Example
Code
return form(['rating' => 4, 'your_rating' => 3])
->stars('rating')
->stars_select('your_rating', 'Your rating');Notes
stars_select()keeps its value only withyf_form2_stars::$SELECT_FIXon (Settings / Widget fixes; the 4.0 default): it starts at the stored rating, marks the chosen stars with the classrating_selectedand posts the choice. Off, as before: the field starts at 0 on every render (an edit form saves 0) and a click marks nothing. Style the chosen stars with.rating span.star.rating_selected:before.
See also: table/stars