File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
lib/html5_validators/action_view Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,13 @@ def inject_maxlength_field
1111 @options [ "maxlength" ] ||= @options [ :maxlength ] || object . class . attribute_maxlength ( @method_name )
1212 end
1313 end
14+
15+ def inject_numericality_fields
16+ if object . class . ancestors . include? ( ActiveModel ::Validations ) && ( object . auto_html5_validation != false ) && ( object . class . auto_html5_validation != false )
17+ @options [ "max" ] ||= @options [ "max" ] || @options [ :max ] || object . class . attribute_max ( @method_name )
18+ @options [ "min" ] ||= @options [ "min" ] || @options [ :min ] || object . class . attribute_min ( @method_name )
19+ end
20+ end
1421 end
1522end
1623
@@ -38,11 +45,8 @@ class TextField
3845 def render_with_html5_attributes
3946 inject_required_field
4047 inject_maxlength_field
48+ inject_numericality_fields
4149
42- if object . class . ancestors . include? ( ActiveModel ::Validations ) && ( object . auto_html5_validation != false ) && ( object . class . auto_html5_validation != false )
43- @options [ "max" ] ||= @options [ "max" ] || @options [ :max ] || object . class . attribute_max ( @method_name )
44- @options [ "min" ] ||= @options [ "min" ] || @options [ :min ] || object . class . attribute_min ( @method_name )
45- end
4650 render_without_html5_attributes
4751 end
4852 alias_method_chain :render , :html5_attributes
You can’t perform that action at this time.
0 commit comments