class Formtastic::Inputs::NumberInput
@see api.rubyonrails.org/classes/ActiveModel/Validations/HelperMethods.html#method-i-validates_numericality_of Rails’ Numericality validation documentation
@see Formtastic::Helpers::InputsHelper#input InputsHelper#input for full documentation of all possible options.
<%= f.input :shoe_size, :as => :number, :input_html => { :in => 3..15, :step => 1 } %>
<%= f.input :shoe_size, :as => :number, :in => 3..15, :step => 1 %>
@example Use :in with a Range as a shortcut for :min/:max
<%= f.input :shoe_size, :as => :number, :min => 3, :max => 15, :step => 1, :input_html => { :class => “special” } %>
@example Min/max/step also work as options
<%= f.input :shoe_size, :as => :number, :input_html => { :min => 3, :max => 15, :step => 1, :class => “special” } %>
@example Pass attributes down to the ‘<input>` tag with :input_html
</li>
<input type=“number” id=“person_age” name=“person” min=“18” max=“100” step=“1”>
<label for=“persom_age”>Age</label>
<li class=“numeric”>
<%= f.input :age, :as => :number %>
end
:only_integer => true
:greater_than_or_equal_to => 18,
:less_than_or_equal_to => 100,
validates_numericality_of :age,
class Person < ActiveRecord::Base
@example Default HTML5 min/max/step attributes are detected from the numericality validations
</form>
</fieldset>
</ol>
</li>
<input type=“number” id=“user_shoe_size” name=“user”>
<label for=“user_shoe_size”>Shoe size</label>
<li class=“numeric”>
<ol>
<fieldset>
<form…>
<% end %>
<% end %>
<%= f.input :shoe_size, :as => :number %>
<%= f.inputs do %>
<%= semantic_form_for(@user) do |f| %>
@example Full form context and output
* change the validations to use `:less_than_or_equal_to` or `:greater_than_or_equal_to`
* change the database column type to an `:integer` (if appropriate)
* manually specify the `:min` or `:max` for the input
The solution is to either:
* the validation uses `:less_than` or `:greater_than`
* the model’s database column type is a ‘:float` or `:decimal`
* you haven’t specified a ‘:min` or `:max` for the input
will be raised when the following conditions are all true:
the model’s validations (when provided). An ‘IndeterminableMinimumAttributeError` exception
Sensible default values for the `min`, `max` and `step` attributes are found by reflecting on
but can be applied to any text-like input with `:as => :number`.
and `:decimal`, as well as `:integer` columns that aren’t used for ‘belongs_to` associations,
`<li>` wrapper. This is the default input choice for all database columns of the type `:float`
Outputs a simple `<label>` with a HTML5 `<input type=“number”>` wrapped in the standard
def step_option
def step_option super || "any" end
def to_html
def to_html input_wrapping do label_html << builder.number_field(method, input_html_options) end end