@@ -21,6 +21,11 @@ def #{selector}(method, options = {}) # def text_field(method, options = {
21
21
end
22
22
end
23
23
24
+ def initialize ( object_name , object , template , options )
25
+ super ( object_name , object , template , options )
26
+ @options [ :validators ] = { object => { } }
27
+ end
28
+
24
29
def client_side_form_settings ( _options , form_helper )
25
30
{
26
31
type : self . class . to_s ,
@@ -37,25 +42,24 @@ def validate(*attrs)
37
42
nil
38
43
end
39
44
40
- def initialize ( object_name , object , template , options )
41
- super ( object_name , object , template , options )
42
- @options [ :validators ] = { object => { } }
45
+ def check_box ( method , options = { } , checked_value = '1' , unchecked_value = '0' )
46
+ build_validation_options ( method , options )
47
+ options . delete ( :validate )
48
+ super ( method , options , checked_value , unchecked_value )
43
49
end
44
50
45
- def fields_for ( record_name , record_object = nil , fields_options = { } , &block )
46
- if record_object . is_a? ( Hash ) && record_object . extractable_options?
47
- fields_options = record_object
48
- record_object = nil
51
+ %i[ collection_check_boxes collection_radio_buttons ] . each do |method_name |
52
+ define_method method_name do |method , collection , value_method , text_method , options = { } , html_options = { } , &block |
53
+ build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
54
+ html_options . delete ( :validate )
55
+ super ( method , collection , value_method , text_method , options , html_options , &block )
49
56
end
50
-
51
- fields_options [ :validate ] ||= @options [ :validate ] if @options [ :validate ] && !fields_options . key? ( :validate )
52
- super ( record_name , record_object , fields_options , &block )
53
57
end
54
58
55
- def check_box ( method , options = { } , checked_value = '1' , unchecked_value = '0' )
56
- build_validation_options ( method , options )
57
- options . delete ( :validate )
58
- super ( method , options , checked_value , unchecked_value )
59
+ def collection_select ( method , collection , value_method , text_method , options = { } , html_options = { } )
60
+ build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
61
+ html_options . delete ( :validate )
62
+ super ( method , collection , value_method , text_method , options , html_options )
59
63
end
60
64
61
65
def radio_button ( method , tag_value , options = { } )
@@ -64,24 +68,20 @@ def radio_button(method, tag_value, options = {})
64
68
super ( method , tag_value , options )
65
69
end
66
70
67
- def select ( method , choices = nil , options = { } , html_options = { } , &block )
68
- build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
69
- html_options . delete ( :validate )
70
- super ( method , choices , options , html_options , & block )
71
- end
71
+ def fields_for ( record_name , record_object = nil , fields_options = { } , &block )
72
+ if record_object . is_a? ( Hash ) && record_object . extractable_options?
73
+ fields_options = record_object
74
+ record_object = nil
75
+ end
72
76
73
- def collection_select ( method , collection , value_method , text_method , options = { } , html_options = { } )
74
- build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
75
- html_options . delete ( :validate )
76
- super ( method , collection , value_method , text_method , options , html_options )
77
+ fields_options [ :validate ] ||= @options [ :validate ] if @options [ :validate ] && !fields_options . key? ( :validate )
78
+ super ( record_name , record_object , fields_options , &block )
77
79
end
78
80
79
- %i[ collection_check_boxes collection_radio_buttons ] . each do |method_name |
80
- define_method method_name do |method , collection , value_method , text_method , options = { } , html_options = { } , &block |
81
- build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
82
- html_options . delete ( :validate )
83
- super ( method , collection , value_method , text_method , options , html_options , &block )
84
- end
81
+ def file_field ( method , options = { } )
82
+ build_validation_options ( method , options )
83
+ options . delete ( :validate )
84
+ super ( method , options )
85
85
end
86
86
87
87
def grouped_collection_select ( method , collection , group_method , group_label_method , option_key_method , option_value_method , options = { } , html_options = { } )
@@ -90,16 +90,16 @@ def grouped_collection_select(method, collection, group_method, group_label_meth
90
90
super ( method , collection , group_method , group_label_method , option_key_method , option_value_method , options , html_options )
91
91
end
92
92
93
- def time_zone_select ( method , priority_zones = nil , options = { } , html_options = { } )
93
+ def select ( method , choices = nil , options = { } , html_options = { } , & block )
94
94
build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
95
95
html_options . delete ( :validate )
96
- super ( method , priority_zones , options , html_options )
96
+ super ( method , choices , options , html_options , & block )
97
97
end
98
98
99
- def file_field ( method , options = { } )
100
- build_validation_options ( method , options )
101
- options . delete ( :validate )
102
- super ( method , options )
99
+ def time_zone_select ( method , priority_zones = nil , options = { } , html_options = { } )
100
+ build_validation_options ( method , html_options . merge ( name : options [ :name ] ) )
101
+ html_options . delete ( :validate )
102
+ super ( method , priority_zones , options , html_options )
103
103
end
104
104
105
105
private
0 commit comments