cirandas.net

ref: master

plugins/responsive/lib/ext/form_builder.rb


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
class ResponsiveFormBuilder < ActionView::Helpers::FormBuilder

  %w[file_field text_field text_area number_field password_field].each do |method|
    define_method method do |*args, &block|
      options = args.extract_options!
      if options['class']
        options['class'] = "#{options['class']} form-control"
      else
        options[:class] = "#{options[:class]} form-control"
      end
      super(*(args << options), &block)
    end
  end

end

ActionView::Base.default_form_builder = ResponsiveFormBuilder