module BootstrapForms::Helpers::Wrappers
Private Instance Methods
addon(&block)
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 89 def addon(&block) [prepend, block[], append].join('').html_safe end
control_group_div(&block)
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 7 def control_group_div(&block) field_errors = error_string if @field_options[:error] (@field_options[:error] << ', ' << field_errors) if field_errors else @field_options[:error] = field_errors end klasses = ['control-group'] klasses << 'error' if @field_options[:error] klasses << 'info' if @field_options[:info] klasses << 'success' if @field_options[:success] klasses << 'warning' if @field_options[:warning] klass = klasses.join(' ') content_tag(:div, block[], :class => klass) end
error_string()
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 25 def error_string if respond_to?(:object) errors = object.errors[@name] if errors.any? errors.map { |e| "#{@field_options[:label] || @name.to_s.humanize} #{e}" }.join(', ') end end end
input_div(include_messages = true, &block)
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 36 def input_div(include_messages = true, &block) if @field_options[:append] || @field_options[:prepend] klasses = [] klasses << 'input-prepend' if @field_options[:prepend] klasses << 'input-append' if @field_options[:append] klass = klasses.join(' ') content = content_tag(:div, addon { block[] }, :class => klass) else content = block[] end content << messages if include_messages content_tag(:div, content, :class => 'controls') end
label_field(&block)
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 51 def label_field(&block) if @field_options[:label] == '' || @field_options[:label] == false return '' else options = { :class => 'control-label' } # Allow for setting for to nil i.e., no for attribute. Padrino will always generate one options[:for] = @field_options[:id] if @field_options.include?(:id) options[:caption] = @field_options[:label] if @field_options[:label] if respond_to?(:object) label(@name, options, &block) else label_tag(@name, options, &block) end end end
messages()
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 85 def messages [help_inline, bootstrap_error, success, warning, info, help_block].join('').html_safe end
objectify_options(options)
click to toggle source
# File lib/bootstrap_forms/helpers/wrappers.rb, line 93 def objectify_options(options) options.except(:label, :help_block, :help_inline, :error, :success, :warning, :info, :prepend, :append) end