number_field_tag
- 1.0.0
- 1.1.6
- 1.2.6
- 2.0.3
- 2.1.0
- 2.2.1
- 2.3.8
- 3.0.0 (0)
- 3.0.9 (-1)
- 3.1.0 (0)
- 3.2.1 (1)
- 3.2.8 (0)
- 3.2.13 (0)
- 4.0.2 (0)
- 4.1.8 (0)
- 4.2.1 (38)
- 4.2.7 (0)
- 4.2.9 (0)
- 5.0.0.1 (0)
- 5.1.7 (0)
- 5.2.3 (0)
- 6.0.0 (0)
- 6.1.3.1 (0)
- 6.1.7.7 (0)
- 7.0.0 (0)
- 7.1.3.2 (1)
- 7.1.3.4 (0)
- What's this?
number_field_tag(name, value = nil, options = {})
public
Creates a number field.
Options
-
:min - The minimum acceptable value.
-
:max - The maximum acceptable value.
-
:in - A range specifying the :min and :max values.
-
:within - Same as :in.
-
:step - The acceptable value granularity.
-
Otherwise accepts the same options as text_field_tag.
Examples
number_field_tag 'quantity' # => <input id="quantity" name="quantity" type="number" /> number_field_tag 'quantity', '1' # => <input id="quantity" name="quantity" type="number" value="1" /> number_field_tag 'quantity', nil, class: 'special_input' # => <input class="special_input" id="quantity" name="quantity" type="number" /> number_field_tag 'quantity', nil, min: 1 # => <input id="quantity" name="quantity" min="1" type="number" /> number_field_tag 'quantity', nil, max: 9 # => <input id="quantity" name="quantity" max="9" type="number" /> number_field_tag 'quantity', nil, in: 1...10 # => <input id="quantity" name="quantity" min="1" max="9" type="number" /> number_field_tag 'quantity', nil, within: 1...10 # => <input id="quantity" name="quantity" min="1" max="9" type="number" /> number_field_tag 'quantity', nil, min: 1, max: 10 # => <input id="quantity" name="quantity" min="1" max="10" type="number" /> number_field_tag 'quantity', nil, min: 1, max: 10, step: 2 # => <input id="quantity" name="quantity" min="1" max="10" step="2" type="number" /> number_field_tag 'quantity', '1', class: 'special_input', disabled: true # => <input disabled="disabled" class="special_input" id="quantity" name="quantity" type="number" value="1" />
number_field tag does not accept the same options as text_field_tag
number_field_tag does not accept the size or maxlength options; the max option for number_field_tag is used to control the size of the field. According to W3 http://www.w3.org/TR/html-markup/input.number.html , placeholder should be accepted, but I don’t find that this works in the way it works for text_field_tag.