2011-12-04 10:15:27 -05:00
|
|
|
module SimpleForm
|
|
|
|
module Components
|
|
|
|
module HTML5
|
|
|
|
def initialize(*)
|
|
|
|
@html5 = false
|
|
|
|
end
|
|
|
|
|
|
|
|
def html5
|
|
|
|
@html5 = true
|
2013-04-11 08:20:32 -04:00
|
|
|
if has_required?
|
|
|
|
input_html_options[:required] = true
|
2013-04-13 18:44:45 -04:00
|
|
|
input_html_options[:'aria-required'] = true
|
2013-04-11 08:20:32 -04:00
|
|
|
end
|
2011-12-05 04:44:02 -05:00
|
|
|
nil
|
2011-12-04 10:15:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def html5?
|
|
|
|
@html5
|
|
|
|
end
|
2011-12-05 04:44:02 -05:00
|
|
|
|
|
|
|
def has_required?
|
2011-12-05 07:11:02 -05:00
|
|
|
# We need to check browser_validations because
|
|
|
|
# some browsers are still checking required even
|
|
|
|
# if novalidate was given.
|
|
|
|
required_field? && SimpleForm.browser_validations
|
2011-12-05 04:44:02 -05:00
|
|
|
end
|
2011-12-04 10:15:27 -05:00
|
|
|
end
|
|
|
|
end
|
2013-01-28 16:02:59 -05:00
|
|
|
end
|