Number Field(ui_number_field)
UiBibz::Ui::Core::Forms::Numbers::NumberField
Usage
This component is an extension of component element. A Ui Bibz component consists of 3 arguments:
# by variable
ui_number_field name, options, html_options
# or by block
ui_number_field options, html_options do
name
end
Examples
Some examples explain how to use the options present in the component.Number Field
ui_text_field "number"
<input type="number" name="number" id="number" class="custom-number">
Append, prepend
ui_number_field 'number', append: ui_glyph("calendar"), prepend: ui_glyph("pencil-alt")
<div class="input-group ui_surround_field">
<span class="input-group-text"><i class="glyph fas fa-calendar"></i></span>
<input type="number" name="number" id="number" class="form-control">
<span class="input-group-text"><i class="glyph fas fa-pencil-alt"></i></span>
</div>
Number Field min, max, step and value
ui_number_field 'number', min: -3, max: 3, step: 0.2, value: 0.40
<input type="number" name="number" id="number" value="0.4" class="custom-number" min="-3" max="3" step="0.2">
Number Field with in or within
ui_number_field 'number', in: 0..100, value: 8
ui_number_field 'number', within: 5..10, step: 0.2, value: 6
<input type="number" name="number" id="number" value="8" class="custom-number" min="0" max="100">
<input type="number" name="number" id="number" value="6" class="custom-number" min="5" max="10" step="0.2">
Simple form
Ui Bibz is compatible with simple form.
You can use defaults inputs of Simple Form and defaults inputs of Ui Bibz like ui_number_field
. You can use Simple Form input options and Ui Bibz ui_number_field options.
ui_form_for(@search) do |f|
...
f.input :name, as: :ui_number_field
...
end