1+ require_relative 'aliasing'
12require_relative 'helpers/bootstrap'
23
34module BootstrapForm
45 class FormBuilder < ActionView ::Helpers ::FormBuilder
6+ extend BootstrapForm ::Aliasing
57 include BootstrapForm ::Helpers ::Bootstrap
68
79 attr_reader :layout , :label_col , :control_col , :has_error , :inline_errors , :label_errors , :acts_like_form_tag
@@ -42,7 +44,7 @@ def initialize(object_name, object, template, options)
4244 end
4345 end
4446
45- alias_method_chain method_name , :bootstrap
47+ bootstrap_method_alias method_name
4648 end
4749
4850 DATE_SELECT_HELPERS . each do |method_name |
@@ -55,7 +57,7 @@ def initialize(object_name, object, template, options)
5557 end
5658 end
5759
58- alias_method_chain method_name , :bootstrap
60+ bootstrap_method_alias method_name
5961 end
6062
6163 def file_field_with_bootstrap ( name , options = { } )
@@ -64,7 +66,7 @@ def file_field_with_bootstrap(name, options = {})
6466 end
6567 end
6668
67- alias_method_chain :file_field , :bootstrap
69+ bootstrap_method_alias :file_field
6870
6971 if Gem ::Version . new ( Rails ::VERSION ::STRING ) >= Gem ::Version . new ( "4.1.0" )
7072 def select_with_bootstrap ( method , choices = nil , options = { } , html_options = { } , &block )
@@ -80,31 +82,31 @@ def select_with_bootstrap(method, choices, options = {}, html_options = {})
8082 end
8183 end
8284
83- alias_method_chain :select , :bootstrap
85+ bootstrap_method_alias :select
8486
8587 def collection_select_with_bootstrap ( method , collection , value_method , text_method , options = { } , html_options = { } )
8688 form_group_builder ( method , options , html_options ) do
8789 collection_select_without_bootstrap ( method , collection , value_method , text_method , options , html_options )
8890 end
8991 end
9092
91- alias_method_chain :collection_select , :bootstrap
93+ bootstrap_method_alias :collection_select
9294
9395 def grouped_collection_select_with_bootstrap ( method , collection , group_method , group_label_method , option_key_method , option_value_method , options = { } , html_options = { } )
9496 form_group_builder ( method , options , html_options ) do
9597 grouped_collection_select_without_bootstrap ( method , collection , group_method , group_label_method , option_key_method , option_value_method , options , html_options )
9698 end
9799 end
98100
99- alias_method_chain :grouped_collection_select , :bootstrap
101+ bootstrap_method_alias :grouped_collection_select
100102
101103 def time_zone_select_with_bootstrap ( method , priority_zones = nil , options = { } , html_options = { } )
102104 form_group_builder ( method , options , html_options ) do
103105 time_zone_select_without_bootstrap ( method , priority_zones , options , html_options )
104106 end
105107 end
106108
107- alias_method_chain :time_zone_select , :bootstrap
109+ bootstrap_method_alias :time_zone_select
108110
109111 def check_box_with_bootstrap ( name , options = { } , checked_value = "1" , unchecked_value = "0" , &block )
110112 options = options . symbolize_keys!
@@ -130,7 +132,7 @@ def check_box_with_bootstrap(name, options = {}, checked_value = "1", unchecked_
130132 end
131133 end
132134
133- alias_method_chain :check_box , :bootstrap
135+ bootstrap_method_alias :check_box
134136
135137 def radio_button_with_bootstrap ( name , value , *args )
136138 options = args . extract_options! . symbolize_keys!
@@ -151,7 +153,7 @@ def radio_button_with_bootstrap(name, value, *args)
151153 end
152154 end
153155
154- alias_method_chain :radio_button , :bootstrap
156+ bootstrap_method_alias :radio_button
155157
156158 def collection_check_boxes_with_bootstrap ( *args )
157159 html = inputs_collection ( *args ) do |name , value , options |
@@ -161,15 +163,15 @@ def collection_check_boxes_with_bootstrap(*args)
161163 hidden_field ( args . first , { value : "" , multiple : true } ) . concat ( html )
162164 end
163165
164- alias_method_chain :collection_check_boxes , :bootstrap
166+ bootstrap_method_alias :collection_check_boxes
165167
166168 def collection_radio_buttons_with_bootstrap ( *args )
167169 inputs_collection ( *args ) do |name , value , options |
168170 radio_button ( name , value , options )
169171 end
170172 end
171173
172- alias_method_chain :collection_radio_buttons , :bootstrap
174+ bootstrap_method_alias :collection_radio_buttons
173175
174176 def check_boxes_collection ( *args )
175177 warn "'BootstrapForm#check_boxes_collection' is deprecated, use 'BootstrapForm#collection_check_boxes' instead"
@@ -218,7 +220,7 @@ def fields_for_with_bootstrap(record_name, record_object = nil, fields_options =
218220 fields_for_without_bootstrap ( record_name , record_object , fields_options , &block )
219221 end
220222
221- alias_method_chain :fields_for , :bootstrap
223+ bootstrap_method_alias :fields_for
222224
223225 private
224226
@@ -276,7 +278,7 @@ def required_attribute?(obj, attribute)
276278
277279 target = ( obj . class == Class ) ? obj : obj . class
278280
279- target_validators = if target . respond_to? :validators_on
281+ target_validators = if target . respond_to? :validators_on
280282 target . validators_on ( attribute ) . map ( &:class )
281283 else
282284 [ ]
0 commit comments