Sha256: 15775c16bbbd9379f7eed8bb17e9fc04a30f61d8d7b12d4581ab8007dd0daa0e
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
module Trestle class Form module Fields class FormGroup < Field WRAPPER_OPTIONS = [:help, :label, :hide_label] def render options[:class] << 'has-error' if errors.any? content_tag(:div, options.except(*WRAPPER_OPTIONS)) do concat label unless options[:label] == false concat template.capture(&block) if block concat help_message if options[:help] concat error_message if errors.any? end end def help_message content_tag(:p, options[:help], class: "help-block") end def error_message content_tag(:p, class: "help-block") do safe_join([icon("fa fa-warning"), errors.first], " ") end end def label builder.label(name, options[:label], class: ["control-label", ("sr-only" if options[:hide_label])].compact) end def defaults super.merge(class: ["form-group"]) end def extract_options! # Do not call super end end end end end Trestle::Form::Builder.register(:form_group, Trestle::Form::Fields::FormGroup)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
trestle-0.8.10 | lib/trestle/form/fields/form_group.rb |
trestle-0.8.9 | lib/trestle/form/fields/form_group.rb |
trestle-0.8.8 | lib/trestle/form/fields/form_group.rb |