11module Html5Validators
22 module ActionViewExtension
3- def inject_required_field
3+ def inject_required_attribute
44 if object . class . ancestors . include? ( ActiveModel ::Validations ) && ( object . auto_html5_validation != false ) && ( object . class . auto_html5_validation != false )
55 @options [ "required" ] ||= @options [ :required ] || object . class . attribute_required? ( @method_name )
66 end
77 end
88
9- def inject_maxlength_field
9+ def inject_maxlength_attribute
1010 if object . class . ancestors . include? ( ActiveModel ::Validations ) && ( object . auto_html5_validation != false ) && ( object . class . auto_html5_validation != false )
1111 @options [ "maxlength" ] ||= @options [ :maxlength ] || object . class . attribute_maxlength ( @method_name )
1212 end
1313 end
1414
15- def inject_numericality_fields
15+ def inject_numericality_attributes
1616 if object . class . ancestors . include? ( ActiveModel ::Validations ) && ( object . auto_html5_validation != false ) && ( object . class . auto_html5_validation != false )
1717 @options [ "max" ] ||= @options [ "max" ] || @options [ :max ] || object . class . attribute_max ( @method_name )
1818 @options [ "min" ] ||= @options [ "min" ] || @options [ :min ] || object . class . attribute_min ( @method_name )
@@ -43,9 +43,9 @@ class Base #:nodoc:
4343
4444 class TextField
4545 def render_with_html5_attributes
46- inject_required_field
47- inject_maxlength_field
48- inject_numericality_fields
46+ inject_required_attribute
47+ inject_maxlength_attribute
48+ inject_numericality_attributes
4949
5050 render_without_html5_attributes
5151 end
@@ -54,8 +54,8 @@ def render_with_html5_attributes
5454
5555 class TextArea
5656 def render_with_html5_attributes
57- inject_required_field
58- inject_maxlength_field
57+ inject_required_attribute
58+ inject_maxlength_attribute
5959
6060 render_without_html5_attributes
6161 end
@@ -66,7 +66,7 @@ def render_with_html5_attributes
6666 [ RadioButton , CheckBox , Select , DateSelect , TimeZoneSelect ] . each do |kls |
6767 kls . class_eval do
6868 def render_with_html5_attributes
69- inject_required_field
69+ inject_required_attribute
7070 render_without_html5_attributes
7171 end
7272 alias_method_chain :render , :html5_attributes
0 commit comments