class Trestle::Form::Fields::FormGroup
Constants
- WRAPPER_OPTIONS
Public Class Methods
new(builder, template, name=nil, options={}, &block)
click to toggle source
Calls superclass method
Trestle::Form::Field::new
# File lib/trestle/form/fields/form_group.rb, line 7 def initialize(builder, template, name=nil, options={}, &block) # Normalize options passed as name parameter name, options = nil, name if name.is_a?(Hash) super(builder, template, name, options, &block) end
Public Instance Methods
defaults()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 48 def defaults Trestle::Options.new(class: ["form-group"]) end
error_messages()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 36 def error_messages content_tag(:ul, class: "invalid-feedback") do safe_join(errors.map { |error| content_tag(:li, safe_join([icon("fa fa-warning"), error], " ")) }, "\n") end end
help_message()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 23 def help_message classes = ["form-text"] if options[:help].is_a?(Hash) message = options[:help][:text] classes << "floating" if options[:help][:float] else message = options[:help] end content_tag(:p, message, class: classes) end
label()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 44 def label builder.label(name, options[:label], class: ["control-label", ("sr-only" if options[:hide_label])].compact) end
render()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 14 def render content_tag(:div, options.except(*WRAPPER_OPTIONS)) do concat label if name && options[:label] != false concat template.capture(&block) if block concat help_message if options[:help] concat error_messages if name && errors.any? end end
Protected Instance Methods
error_class()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 57 def error_class "has-error" end
error_keys()
click to toggle source
Calls superclass method
Trestle::Form::Field#error_keys
# File lib/trestle/form/fields/form_group.rb, line 61 def error_keys name ? super : [] end
extract_wrapper_options!()
click to toggle source
# File lib/trestle/form/fields/form_group.rb, line 53 def extract_wrapper_options! # Intentional no-op end