class Trestle::Form::Fields::FormControl
Public Instance Methods
defaults()
click to toggle source
Calls superclass method
Trestle::Form::Field#defaults
# File lib/trestle/form/fields/form_control.rb, line 33 def defaults super.merge(class: ["form-control"]) end
input_group() { || ... }
click to toggle source
# File lib/trestle/form/fields/form_control.rb, line 13 def input_group if @prepend || @append content_tag(:div, class: "input-group") do concat content_tag(:div, input_group_addon(@prepend), class: "input-group-prepend") if @prepend concat yield concat content_tag(:div, input_group_addon(@append), class: "input-group-append") if @append end else yield end end
input_group_addon(addon)
click to toggle source
# File lib/trestle/form/fields/form_control.rb, line 25 def input_group_addon(addon) if addon[:wrap] content_tag(:span, addon[:content], class: "input-group-text") else addon[:content] end end
normalize_options!()
click to toggle source
Calls superclass method
Trestle::Form::Field#normalize_options!
# File lib/trestle/form/fields/form_control.rb, line 37 def normalize_options! super @prepend = { content: options.delete(:prepend), wrap: true } if options[:prepend] @prepend = { content: options.delete(:prepend!), wrap: false } if options[:prepend!] @append = { content: options.delete(:append), wrap: true } if options[:append] @append = { content: options.delete(:append!), wrap: false } if options[:append!] end
render()
click to toggle source
# File lib/trestle/form/fields/form_control.rb, line 5 def render form_group do input_group do field end end end