Module: Formtastic::Inputs::Base::Wrapping
- Included in:
- Formtastic::Inputs::Base
- Defined in:
- lib/formtastic/inputs/base/wrapping.rb
Overview
TODO:
relies on ‘dom_id`, `required?`, `optional`, `errors?`, `association_primary_key` & `sanitized_method_name` methods from another module
Instance Method Summary collapse
-
#input_wrapping(&block) ⇒ Object
Override this method if you want to change the display order (for example, rendering the errors before the body of the input).
- #wrapper_dom_id ⇒ Object
- #wrapper_html_options ⇒ Object
Instance Method Details
#input_wrapping(&block) ⇒ Object
Override this method if you want to change the display order (for example, rendering the errors before the body of the input).
9 10 11 12 13 14 |
# File 'lib/formtastic/inputs/base/wrapping.rb', line 9 def input_wrapping(&block) template.content_tag(:li, [template.capture(&block), error_html, hint_html].join("\n").html_safe, ) end |
#wrapper_dom_id ⇒ Object
31 32 33 |
# File 'lib/formtastic/inputs/base/wrapping.rb', line 31 def wrapper_dom_id @wrapper_dom_id ||= "#{dom_id.to_s.gsub((association_primary_key || method).to_s, sanitized_method_name.to_s)}_input" end |
#wrapper_html_options ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/formtastic/inputs/base/wrapping.rb', line 16 def opts = [:wrapper_html] || {} opts[:class] ||= [] opts[:class] = [opts[:class].to_s] unless opts[:class].is_a?(Array) opts[:class] << as opts[:class] << "error" if errors? opts[:class] << "optional" if optional? opts[:class] << "required" if required? opts[:class] = opts[:class].join(' ') opts[:id] ||= wrapper_dom_id opts end |