module Bh::Rails::Helpers
Public Instance Methods
form_for(record, options = {}, &block)
click to toggle source
Calls superclass method
# File lib/bh/core_ext/rails/form_for_helper.rb, line 10 def form_for(record, options = {}, &block) options[:layout] ||= 'navbar' if Bh::Stack.find(Bh::Navbar) add_form_options!(options) if options[:layout] html = super record, options, &block if Bh::Stack.find(Bh::Nav) container = Bh::Base.new(self) { html } container.render_tag :li else html end end
Private Instance Methods
add_form_options!(options)
click to toggle source
# File lib/bh/core_ext/rails/form_for_helper.rb, line 25 def add_form_options!(options) options[:html] ||= {} options[:html].merge! role: 'form' append_class! options[:html], class_for(options[:layout]) options.merge! builder: FormBuilder end
class_for(layout)
click to toggle source
# File lib/bh/core_ext/rails/form_for_helper.rb, line 32 def class_for(layout) case layout.to_s when 'navbar' then 'navbar-form' when 'inline' then 'form-inline' when 'horizontal' then 'form-horizontal' end end