Sha256: 6d8db37c25ee34145f63da61a79df7f4b1b48a4dd8191ba447a233e71a422c2f
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
module BootstrapForm module Helper def bootstrap_form_for(object, options = {}, &block) options.reverse_merge!({builder: BootstrapForm::FormBuilder}) options = process_options(options) temporarily_disable_field_error_proc do form_for(object, options, &block) end end def bootstrap_form_tag(options = {}, &block) options[:acts_like_form_tag] = true bootstrap_form_for("", options, &block) end def bootstrap_form_with(options = {}, &block) options.reverse_merge!(builder: BootstrapForm::FormBuilder) options = process_options(options) temporarily_disable_field_error_proc do form_with(options, &block) end end private def process_options(options) options[:html] ||= {} options[:html][:role] ||= 'form' if options[:layout] == :inline options[:html][:class] = [options[:html][:class], 'form-inline'].compact.join(' ') end options end public def temporarily_disable_field_error_proc original_proc = ActionView::Base.field_error_proc ActionView::Base.field_error_proc = proc { |input, instance| input } yield ensure ActionView::Base.field_error_proc = original_proc end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bootstrap_form-4.0.0 | lib/bootstrap_form/helper.rb |
bootstrap_form-4.0.0.alpha1 | lib/bootstrap_form/helper.rb |