1
0
Fork 0
mirror of https://github.com/heartcombo/simple_form.git synced 2022-11-09 12:19:26 -05:00
heartcombo--simple_form/lib/simple_form/wrappers/root.rb

26 lines
738 B
Ruby
Raw Normal View History

module SimpleForm
module Wrappers
2011-09-03 03:15:47 -04:00
# `Root` is the root wrapper for all components. It is special cased to
# always have a namespace and to add special html classes.
class Root < Many
def initialize(*args)
super(:wrapper, *args)
end
2011-09-04 05:31:24 -04:00
# Provide a fallback if name cannot be found.
def find(name)
super || SingleForm::Wrappers::Many.new(name, [name])
end
private
def html_classes(input, options)
css = options[:wrapper_class] ? Array.wrap(options[:wrapper_class]) : @defaults[:class]
css += input.input_html_classes
css << (options[:wrapper_error_class] || @defaults[:error_class]) if input.has_errors?
2011-09-11 17:46:47 -04:00
css
end
end
end
2011-09-11 17:46:47 -04:00
end