Class: Formtastic::Inputs::RangeInput
- Inherits:
-
Object
- Object
- Formtastic::Inputs::RangeInput
- Includes:
- Base, Base::Numeric
- Defined in:
- lib/formtastic/inputs/range_input.rb
Overview
Outputs a simple <label>
with a HTML5 <input type="range">
wrapped in the standard
<li>
wrapper. This is an alternative input choice to a number input.
Sensible default for the min
, max
and step
attributes are found by reflecting on
the model's validations. When validations are not provided, the min
and step
default to
1
and the max
default to 100
. An IndeterminableMinimumAttributeError
exception
will be raised when the following conditions are all true:
- you haven't specified a
:min
or:max
for the input - the model's database column type is a
:float
or:decimal
- the validation uses
:less_than
or:greater_than
The solution is to either:
- manually specify the
:min
or:max
for the input - change the database column type to an
:integer
(if appropriate) - change the validations to use
:less_than_or_equal_to
or:greater_than_or_equal_to
Instance Attribute Summary
Attributes included from Base
#builder, #method, #object, #object_name, #options, #template
Instance Method Summary collapse
Methods included from Base::Numeric
#in_option, #input_html_options, #wrapper_html_options
Methods included from Base
#initialize, #removed_option!, #warn_and_correct_option!, #warn_deprecated_option!
Methods included from Base::Wrapping
#input_wrapping, #wrapper_classes, #wrapper_classes_raw, #wrapper_dom_id, #wrapper_html_options, #wrapper_html_options_raw
Methods included from Base::Labelling
#label_from_options, #label_html, #label_html_options, #label_text, #localized_label, #render_label?, #requirement_text, #requirement_text_or_proc
Methods included from LocalizedString
Methods included from Base::Associations
#association, #association_primary_key, #belongs_to?, #has_many?, #reflection
Methods included from Base::Fileish
Methods included from Base::Validations
#autofocus?, #column_limit, #limit, #not_required_through_negated_validation!, #not_required_through_negated_validation?, #optional?, #readonly?, #readonly_attribute?, #readonly_from_options?, #required?, #required_attribute?, #responds_to_global_required?, #validation_integer_only?, #validation_limit, #validation_max, #validation_min, #validation_step, #validations, #validations?, #validator_relevant?
Methods included from Base::Naming
#as, #attributized_method_name, #humanized_method_name, #input_name, #sanitized_method_name, #sanitized_object_name
Methods included from Base::Hints
#hint?, #hint_html, #hint_text, #hint_text_from_options
Methods included from Base::Errors
#error_first_html, #error_html, #error_keys, #error_list_html, #error_none_html, #error_sentence_html, #errors, #errors?
Methods included from Base::Database
Methods included from Base::Options
#formtastic_options, #input_options
Methods included from Base::Html
#dom_id, #dom_index, #input_html_options
Instance Method Details
#max_option ⇒ Object
86 87 88 |
# File 'lib/formtastic/inputs/range_input.rb', line 86 def max_option super || 100 end |
#min_option ⇒ Object
82 83 84 |
# File 'lib/formtastic/inputs/range_input.rb', line 82 def min_option super || 1 end |
#step_option ⇒ Object
90 91 92 |
# File 'lib/formtastic/inputs/range_input.rb', line 90 def step_option super || 1 end |
#to_html ⇒ Object
75 76 77 78 79 80 |
# File 'lib/formtastic/inputs/range_input.rb', line 75 def to_html input_wrapping do label_html << builder.range_field(method, ) end end |