Sha256: d483ce56936e631b7f439f97c6531c5e1854c45521f9c146e98a6c3308762261

Contents?: true

Size: 972 Bytes

Versions: 5

Compression:

Stored size: 972 Bytes

Contents

module SimpleForm
  module Components
    module HTML5
      def initialize(*)
        @html5 = false
      end

      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

      def html5?
        @html5
      end

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

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

      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
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
simple_form-3.5.0 lib/simple_form/components/html5.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/simple_form-3.4.0/lib/simple_form/components/html5.rb
simple_form-3.4.0 lib/simple_form/components/html5.rb
simple_form-3.3.1 lib/simple_form/components/html5.rb
simple_form-3.3.0 lib/simple_form/components/html5.rb