Class: Inputs::EffectivePrice::Input
- Inherits:
-
Effective::FormInput
- Object
- Effective::FormInput
- Inputs::EffectivePrice::Input
- Defined in:
- app/models/inputs/effective_price/input.rb
Instance Method Summary collapse
- #default_input_html ⇒ Object
- #price ⇒ Object
-
#price_field ⇒ Object
These two are for the hidden input.
- #to_html ⇒ Object
- #value ⇒ Object
Methods inherited from Effective::FormInput
#field_name, #html_options, #initialize, #js_options, #options
Constructor Details
This class inherits a constructor from Effective::FormInput
Instance Method Details
#default_input_html ⇒ Object
6 7 8 |
# File 'app/models/inputs/effective_price/input.rb', line 6 def default_input_html {class: 'effective_price numeric', maxlength: 14, autocomplete: 'off'} end |
#price ⇒ Object
34 35 36 37 |
# File 'app/models/inputs/effective_price/input.rb', line 34 def price val = (@value || 0) # This is 'super' val.kind_of?(Integer) ? val : (val * 100.0).to_i end |
#price_field ⇒ Object
These two are for the hidden input
30 31 32 |
# File 'app/models/inputs/effective_price/input.rb', line 30 def price_field "#{field_name.parameterize.gsub('-', '_')}_value_as_integer" end |
#to_html ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'app/models/inputs/effective_price/input.rb', line 10 def to_html if [:input_group] == false return text_field_tag(field_name, value, ) + hidden_field_tag(field_name, price, id: price_field) end content_tag(:div, class: 'input-group') do content_tag(:span, '$', class: 'input-group-addon') do content_tag(:i, '', class: 'glyphicon glyphicon-usd').html_safe end + text_field_tag(field_name, number_to_currency(value, unit: ''), ) + hidden_field_tag(field_name, price, id: price_field) end end |
#value ⇒ Object
24 25 26 27 |
# File 'app/models/inputs/effective_price/input.rb', line 24 def value val = (@value || 0) # This is 'super' val.kind_of?(Integer) ? ('%.2f' % (val / 100.0)) : ('%.2f' % val) end |