2011-12-04 15:15:27 +00:00
|
|
|
module SimpleForm
|
|
|
|
module Components
|
|
|
|
module HTML5
|
|
|
|
def initialize(*)
|
|
|
|
@html5 = false
|
|
|
|
end
|
|
|
|
|
2014-03-11 22:41:25 +00:00
|
|
|
def html5(wrapper_options = nil)
|
2011-12-04 15:15:27 +00:00
|
|
|
@html5 = true
|
2015-05-03 17:02:56 +00:00
|
|
|
|
|
|
|
input_html_options[:required] = has_required?
|
|
|
|
input_html_options[:'aria-required'] = has_required? || nil
|
|
|
|
|
2011-12-05 09:44:02 +00:00
|
|
|
nil
|
2011-12-04 15:15:27 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def html5?
|
|
|
|
@html5
|
|
|
|
end
|
2011-12-05 09:44:02 +00:00
|
|
|
|
|
|
|
def has_required?
|
2011-12-05 12:11:02 +00: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 09:44:02 +00:00
|
|
|
end
|
2011-12-04 15:15:27 +00:00
|
|
|
end
|
|
|
|
end
|
2013-01-28 21:02:59 +00:00
|
|
|
end
|