module FormtasticRebootstrap::Inputs::Base::Wrapping
Public Instance Methods
add_on_content(content)
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 55 def add_on_content(content) return nil unless content template.content_tag(:span, content, :class => 'input-group-addon') end
add_on_wrapper_classes(options)
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 74 def add_on_wrapper_classes(options) [:prepend, :append, :prepend_content, :append_content].find do |key| options.has_key?(key) end ? ['input-group'] : [] end
bootstrap_wrapping(&block)
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 8 def bootstrap_wrapping(&block) form_group_wrapping do label_html << template.content_tag(:span, :class => wrapping_class_with_col&.uniq&.join(' ')) do input_content(&block) << hint_html(:block) << error_html(:block) end end end
form_group_wrapping(&block)
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 60 def form_group_wrapping(&block) template.content_tag(:div, template.capture(&block).html_safe, wrapper_html_options ) end
input_content() { || ... }
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 35 def input_content(&block) content = [ add_on_content(options[:prepend]), options[:prepend_content], yield, add_on_content(options[:append]), options[:append_content] ].compact.join("\n").html_safe if prepended_or_appended?(options) template.content_tag(:div, content, :class => add_on_wrapper_classes(options).join(" ")) else content end end
input_default_col()
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 23 def input_default_col 'col-md-9' end
input_options_classes()
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 19 def input_options_classes options.dig(:input_html, :class)&.split(' ')&.flatten end
prepended_or_appended?(options)
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 51 def prepended_or_appended?(options) options[:prepend] || options[:prepend_content] || options[:append] || options[:append_content] end
wrapper_html_options()
click to toggle source
Calls superclass method
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 67 def wrapper_html_options super.tap do |options| options[:class] << " form-group form-row" options[:class] << " has-error" if errors? end end
wrapping_class_with_col()
click to toggle source
# File lib/formtastic_rebootstrap/inputs/base/wrapping.rb, line 27 def wrapping_class_with_col return ['form-wrapper'] << input_default_col unless input_options_classes options[:input_html][:class] = options.dig(:input_html, :class)&.split(' ') ['form-wrapper'] << input_options_classes&.select do |c| c.match(/^col-(sm|md|lg|xl)?-?[0-9]{1,2}/) end end