Skip to content

Commit a14cc22

Browse files
committed
Indentation ◀️ ◀️
1 parent 4a3d8e8 commit a14cc22

File tree

2 files changed

+57
-57
lines changed

2 files changed

+57
-57
lines changed

lib/html5_validators/action_view/form_helpers.rb

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -29,45 +29,45 @@ def form_for_with_auto_html5_validation_option(record, options = {}, &proc)
2929
alias_method_chain :form_for, :auto_html5_validation_option
3030
end
3131

32-
module Tags
33-
class Base #:nodoc:
34-
include Html5Validators::ActionViewExtension
35-
end
32+
module Tags
33+
class Base #:nodoc:
34+
include Html5Validators::ActionViewExtension
35+
end
3636

37-
class TextField
38-
def render_with_html5_attributes
39-
inject_required_field
40-
inject_maxlength_field
37+
class TextField
38+
def render_with_html5_attributes
39+
inject_required_field
40+
inject_maxlength_field
4141

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
46-
render_without_html5_attributes
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)
4745
end
48-
alias_method_chain :render, :html5_attributes
46+
render_without_html5_attributes
47+
end
48+
alias_method_chain :render, :html5_attributes
49+
end
50+
51+
class TextArea
52+
def render_with_html5_attributes
53+
inject_required_field
54+
inject_maxlength_field
55+
56+
render_without_html5_attributes
4957
end
58+
alias_method_chain :render, :html5_attributes
59+
end
5060

51-
class TextArea
61+
#TODO probably I have to add some more classes here
62+
[RadioButton, CheckBox, Select, DateSelect, TimeZoneSelect].each do |kls|
63+
kls.class_eval do
5264
def render_with_html5_attributes
5365
inject_required_field
54-
inject_maxlength_field
55-
5666
render_without_html5_attributes
5767
end
5868
alias_method_chain :render, :html5_attributes
5969
end
60-
61-
#TODO probably I have to add some more classes here
62-
[RadioButton, CheckBox, Select, DateSelect, TimeZoneSelect].each do |kls|
63-
kls.class_eval do
64-
def render_with_html5_attributes
65-
inject_required_field
66-
render_without_html5_attributes
67-
end
68-
alias_method_chain :render, :html5_attributes
69-
end
70-
end
7170
end
71+
end
7272
end
7373
end

lib/html5_validators/action_view/form_helpers_rails3.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,42 +12,42 @@ def form_for_with_auto_html5_validation_option(record, options = {}, &proc)
1212
alias_method_chain :form_for, :auto_html5_validation_option
1313
end
1414

15-
class InstanceTag
16-
def to_input_field_tag_with_html5_attributes(field_type, options = {})
17-
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
18-
options["required"] ||= object.class.attribute_required?(method_name)
19-
options["maxlength"] ||= object.class.attribute_maxlength(method_name)
20-
options["max"] ||= object.class.attribute_max(method_name)
21-
options["min"] ||= object.class.attribute_min(method_name)
22-
end
23-
to_input_field_tag_without_html5_attributes field_type, options
15+
class InstanceTag
16+
def to_input_field_tag_with_html5_attributes(field_type, options = {})
17+
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
18+
options["required"] ||= object.class.attribute_required?(method_name)
19+
options["maxlength"] ||= object.class.attribute_maxlength(method_name)
20+
options["max"] ||= object.class.attribute_max(method_name)
21+
options["min"] ||= object.class.attribute_min(method_name)
2422
end
25-
alias_method_chain :to_input_field_tag, :html5_attributes
23+
to_input_field_tag_without_html5_attributes field_type, options
24+
end
25+
alias_method_chain :to_input_field_tag, :html5_attributes
2626

27-
def to_text_area_tag_with_html5_attributes(options = {})
28-
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
29-
options["required"] ||= object.class.attribute_required?(method_name)
30-
options["maxlength"] ||= object.class.attribute_maxlength(method_name)
31-
end
32-
to_text_area_tag_without_html5_attributes options
27+
def to_text_area_tag_with_html5_attributes(options = {})
28+
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
29+
options["required"] ||= object.class.attribute_required?(method_name)
30+
options["maxlength"] ||= object.class.attribute_maxlength(method_name)
3331
end
34-
alias_method_chain :to_text_area_tag, :html5_attributes
32+
to_text_area_tag_without_html5_attributes options
33+
end
34+
alias_method_chain :to_text_area_tag, :html5_attributes
3535

36-
def to_radio_button_tag_with_html5_attributes(tag_value, options = {})
37-
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
38-
options["required"] ||= object.class.attribute_required?(method_name)
39-
end
40-
to_radio_button_tag_without_html5_attributes tag_value, options
36+
def to_radio_button_tag_with_html5_attributes(tag_value, options = {})
37+
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
38+
options["required"] ||= object.class.attribute_required?(method_name)
4139
end
42-
alias_method_chain :to_radio_button_tag, :html5_attributes
40+
to_radio_button_tag_without_html5_attributes tag_value, options
41+
end
42+
alias_method_chain :to_radio_button_tag, :html5_attributes
4343

44-
def to_check_box_tag_with_html5_attributes(options = {}, checked_value = "1", unchecked_value = "0")
45-
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
46-
options["required"] ||= object.class.attribute_required?(method_name)
47-
end
48-
to_check_box_tag_without_html5_attributes options, checked_value, unchecked_value
44+
def to_check_box_tag_with_html5_attributes(options = {}, checked_value = "1", unchecked_value = "0")
45+
if object.class.ancestors.include?(ActiveModel::Validations) && (object.auto_html5_validation != false) && (object.class.auto_html5_validation != false)
46+
options["required"] ||= object.class.attribute_required?(method_name)
4947
end
50-
alias_method_chain :to_check_box_tag, :html5_attributes
48+
to_check_box_tag_without_html5_attributes options, checked_value, unchecked_value
5149
end
50+
alias_method_chain :to_check_box_tag, :html5_attributes
51+
end
5252
end
5353
end

0 commit comments

Comments
 (0)