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/required_helpers.rb

21 lines
476 B
Ruby
Raw Normal View History

module SimpleForm
module RequiredHelpers
def attribute_required?
2009-12-10 08:23:48 -05:00
options[:required] != false
end
def required_class
attribute_required? ? :required : :optional
end
def default_css_classes(merge_class=nil)
2009-12-10 08:23:48 -05:00
"#{input_type} #{required_class} #{merge_class}".strip
end
def component_html_options
html_options = super
html_options[:class] = default_css_classes(html_options[:class])
html_options
end
end
end