Class: ActionView::Helpers::InstanceTag

Inherits:
Object
  • Object
show all
Defined in:
lib/html5_validators/action_view/form_helpers.rb

Overview

ActionPack::VERSION::STRING == ‘3’

Instance Method Summary collapse

Instance Method Details

#to_check_box_tag_with_html5_attributes(options = {}, checked_value = "1", unchecked_value = "0") ⇒ Object



99
100
101
102
103
104
# File 'lib/html5_validators/action_view/form_helpers.rb', line 99

def to_check_box_tag_with_html5_attributes(options = {}, checked_value = "1", unchecked_value = "0")
  if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
    options["required"] ||= object.class.attribute_required?(method_name)
  end
  to_check_box_tag_without_html5_attributes options, checked_value, unchecked_value
end

#to_input_field_tag_with_html5_attributes(field_type, options = {}) ⇒ Object



71
72
73
74
75
76
77
78
79
# File 'lib/html5_validators/action_view/form_helpers.rb', line 71

def to_input_field_tag_with_html5_attributes(field_type, options = {})
  if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
    options["required"] ||= object.class.attribute_required?(method_name)
    options["maxlength"] ||= object.class.attribute_maxlength(method_name)
    options["max"] ||= object.class.attribute_max(method_name)
    options["min"] ||= object.class.attribute_min(method_name)
  end
  to_input_field_tag_without_html5_attributes field_type, options
end

#to_radio_button_tag_with_html5_attributes(tag_value, options = {}) ⇒ Object



91
92
93
94
95
96
# File 'lib/html5_validators/action_view/form_helpers.rb', line 91

def to_radio_button_tag_with_html5_attributes(tag_value, options = {})
  if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
    options["required"] ||= object.class.attribute_required?(method_name)
  end
  to_radio_button_tag_without_html5_attributes tag_value, options
end

#to_text_area_tag_with_html5_attributes(options = {}) ⇒ Object



82
83
84
85
86
87
88
# File 'lib/html5_validators/action_view/form_helpers.rb', line 82

def to_text_area_tag_with_html5_attributes(options = {})
  if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
    options["required"] ||= object.class.attribute_required?(method_name)
    options["maxlength"] ||= object.class.attribute_maxlength(method_name)
  end
  to_text_area_tag_without_html5_attributes options
end