Sha256: 0afcd787506af4a91d1da7dbf312ef671795a44e573ecc7f7e1b3f32bd259716
Contents?: true
Size: 1.21 KB
Versions: 5
Compression:
Stored size: 1.21 KB
Contents
module AbstractInterface module FormBuilders class ThemedFormBuilder < ActionView::Helpers::FormBuilder include AbstractFormBuilder helpers = field_helpers + %w{date_select datetime_select time_select} + %w{collection_select select country_select time_zone_select} - %w{hidden_field fields_for submit} # Don't decorate these helpers.each do |name| define_method(name) do |field, *args| options = args.extract_options! args << options label = if object.class.respond_to? :human_attribute_name object.class.try(:human_attribute_name, field) else object.t field end options[:label] = label unless options.include? :label inject_styles! options, name input = super field, *args remove_styles! options custom_helper input, options, field, object, *args end end def error_messages errors = object.errors.on(:base) || [] custom_error_messages errors end protected def object @object ||= @template.instance_variable_get "@#{@object_name}" end end end end
Version data entries
5 entries across 5 versions & 2 rubygems