mirror of
https://github.com/heartcombo/simple_form.git
synced 2022-11-09 12:19:26 -05:00
ba05460415
This helps styling disabled elements inside the wrapper.
38 lines
908 B
Ruby
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
|