Sha256: 14fc2714be468b45c9eb60e893afc34f4cbf4d814acdaec3380e501a53014aac
Contents?: true
Size: 1.16 KB
Versions: 5
Compression:
Stored size: 1.16 KB
Contents
class MiscFormBuilder < Formtastic::SemanticFormBuilder @@all_fields_required_by_default = false def foldable_inputs(*args, &block) opts = args.extract_options! unfolded = !(opts[:class] || '').index('off').nil? || @object.new_record? || !@object.errors.empty? opts[:class] = (opts[:class] || '') + " inputs foldable #{'folded' unless unfolded}" args.push(opts) self.inputs(*args, &block) end def custom_input(name, options = {}, &block) default_options = { :css => '', :with_label => true, :label => nil } options = default_options.merge(options) html = options[:with_label] ? self.label(options[:label] || name) : '' html += template.capture(&block) || '' html += self.errors_on(name) || '' template.content_tag(:li, template.find_and_preserve(html), :class => "#{options[:css]} #{'error' unless @object.errors[name].empty?}") end def inline_errors_on(method, options = nil) if render_inline_errors? errors = @object.errors[method.to_sym] template.content_tag(:span, [*errors].to_sentence.untaint, :class => 'inline-errors') if errors.present? else nil end end end
Version data entries
5 entries across 5 versions & 1 rubygems