Module: SimpleForm::Components::HTML5

Included in:
Inputs::Base
Defined in:
lib/simple_form/components/html5.rb

Instance Method Summary collapse

Instance Method Details

#has_required?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
# File 'lib/simple_form/components/html5.rb', line 32

def has_required?
  # We need to check browser_validations because
  # some browsers are still checking required even
  # if novalidate was given.
  required_field? && SimpleForm.browser_validations
end

#html5(wrapper_options = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/simple_form/components/html5.rb', line 9

def html5(wrapper_options = nil)
  @html5 = true

  input_html_options[:required]        = input_html_required_option
  input_html_options[:'aria-required'] = input_html_aria_required_option

  input_html_options[:'aria-invalid']  = has_errors? || nil

  nil
end

#html5?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/simple_form/components/html5.rb', line 20

def html5?
  @html5
end

#initializeObject



5
6
7
# File 'lib/simple_form/components/html5.rb', line 5

def initialize(*)
  @html5 = false
end

#input_html_aria_required_optionObject



28
29
30
# File 'lib/simple_form/components/html5.rb', line 28

def input_html_aria_required_option
  !options[:required].nil? ? (required_field? || nil) : (has_required? || nil)
end

#input_html_required_optionObject



24
25
26
# File 'lib/simple_form/components/html5.rb', line 24

def input_html_required_option
  !options[:required].nil? ? required_field? : has_required?
end