Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added controls class to all output.

  • Loading branch information...
commit 602ff800df882aa0065ed9db2c6a54dcf6a7d192 1 parent 5f711e9
@suranyami authored
Showing with 16 additions and 5 deletions.
  1. +16 −5 lib/formtastic-bootstrap/helpers/input_helper.rb
View
21 lib/formtastic-bootstrap/helpers/input_helper.rb
@@ -8,12 +8,23 @@ def standard_input_class_name(as)
end
def input(method, options = {})
- options[:wrapper_html] ||= {}
- options[:wrapper_html][:class] ||= []
- options[:wrapper_html][:class] << 'control-group'
- options[:inner_html][:class] << 'controls'
+ options[:wrapper_html] = {} unless options[:wrapper_html]
+ add_class(options[:wrapper_html], 'control-group')
+ options[:input_html] = {} unless options[:input_html]
+ add_class(options[:input_html], 'controls')
+ super(method, options)
+ end
+ private
+ def add_class(element, css_class)
+ classes = element[:class]
+ classes = [] unless classes
+ if classes.is_a? String
+ element[:class] = [classes]
+ else
+ element[:class] = classes
+ end
+ element[:class] << css_class
end
end
-
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.