ui_range() form()

A jQuery UI slider for one value or a range, with hidden inputs that post the values.

form()->ui_range($name, $desc = '', $extra = [], $replace = [])

Options

OptionMeaning
min, max, stepLimits and step.
rangetrue for two handles (value_min, value_max).
value, value_min, value_max, valuesStart values; with yf_form2_ui_range::$VALUE_FIX the field value ($replace[name], $replace[name_and], then the filter) comes first.
orientation, animate, disabledSlider options.
feedback, create_inputs, hidden_inputsShow the values; post them through inputs.
slide_event, change_event, start_event, stop_event, create_eventJavaScript bodies of the slider events (site code).

Example

Code

return form(['price_from' => 100, 'price_to' => 400])
    ->ui_range('price', 'Price', ['min' => 0, 'max' => 1000, 'step' => 10, 'range' => true, 'value_min' => 100, 'value_max' => 400]);

Notes

  • Needs jQuery UI; for a plain slider without scripts use range().
  • The second value posts as <name>_and. Only with yf_form2_ui_range::$VALUE_FIX on (Settings / Widget fixes; the 4.0 default) does the slider start at the field value, fill its inputs when moved and use step; off, as before, it shows value_min / value_max on every render and moving it changes no posted value.

See also: form/html5_inputs, demo:form/jquery_widgets