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/components/wrapper.rb
Carlos Antonio da Silva ba05460415 Add "disabled" class to wrapper tag when the input is disabled
This helps styling disabled elements inside the wrapper.
2010-11-21 22:07:23 -02:00

38 lines
908 B
Ruby

module SimpleForm
module Components
module Wrapper
def wrap(content)
if wrapper_tag && options[:wrapper] != false
template.content_tag(wrapper_tag, content, wrapper_html_options)
else
content
end
end
def wrapper_tag
options[:wrapper_tag] || SimpleForm.wrapper_tag
end
def wrapper_class
options[:wrapper_class] || SimpleForm.wrapper_class
end
def wrapper_error_class
options[:wrapper_error_class] || SimpleForm.wrapper_error_class
end
def wrapper_html_options
css_classes = input_html_classes.unshift(wrapper_class)
css_classes << wrapper_error_class if has_errors?
css_classes << disabled_class if disabled?
html_options_for(:wrapper, css_classes)
end
private
def disabled_class
'disabled'
end
end
end
end