@@ -29,9 +29,8 @@ class Builder < ActionView::Helpers::FormBuilder
2929
3030 # Render multiple input controls together with a label for the given
3131 # attributes.
32- def labeled_input_fields ( *attrs )
33- options = attrs . extract_options!
34- safe_join ( attrs ) { |a | labeled_input_field ( a , options . dup ) }
32+ def labeled_input_fields ( *attrs , **options )
33+ safe_join ( attrs ) { |a | labeled_input_field ( a , **options . dup ) }
3534 end
3635
3736 # Render a corresponding input control and label for the given attribute.
@@ -45,8 +44,8 @@ def labeled_input_fields(*attrs)
4544 # * <tt>:field_method</tt> - Different method to create the input field.
4645 #
4746 # Use additional html_options for the input element.
48- def labeled_input_field ( attr , html_options = { } )
49- control_class . new ( self , attr , html_options ) . render_labeled
47+ def labeled_input_field ( attr , ** html_options )
48+ control_class . new ( self , attr , ** html_options ) . render_labeled
5049 end
5150
5251 # Render a corresponding input control for the given attribute.
@@ -59,18 +58,18 @@ def labeled_input_field(attr, html_options = {})
5958 # * <tt>:field_method</tt> - Different method to create the input field.
6059 #
6160 # Use additional html_options for the input element.
62- def input_field ( attr , html_options = { } )
63- control_class . new ( self , attr , html_options ) . render_content
61+ def input_field ( attr , ** html_options )
62+ control_class . new ( self , attr , ** html_options ) . render_content
6463 end
6564
6665 # Render a standard string field with column contraints.
67- def string_field ( attr , html_options = { } )
66+ def string_field ( attr , ** html_options )
6867 html_options [ :maxlength ] ||= column_property ( @object , attr , :limit )
69- text_field ( attr , html_options )
68+ text_field ( attr , ** html_options )
7069 end
7170
7271 # Render a boolean field.
73- def boolean_field ( attr , html_options = { } )
72+ def boolean_field ( attr , ** html_options )
7473 tag . div ( class : 'checkbox' ) do
7574 tag . label do
7675 detail = html_options . delete ( :detail ) || ' ' . html_safe
@@ -82,47 +81,47 @@ def boolean_field(attr, html_options = {})
8281 # Add form-control class to all input fields.
8382 %w[ text_field password_field email_field
8483 number_field date_field time_field datetime_field ] . each do |method |
85- define_method ( method ) do |attr , html_options = { } |
84+ define_method ( method ) do |attr , ** html_options |
8685 add_css_class ( html_options , 'form-control' )
8786 super ( attr , html_options )
8887 end
8988 end
9089
91- def integer_field ( attr , html_options = { } )
90+ def integer_field ( attr , ** html_options )
9291 html_options [ :step ] ||= 1
93- number_field ( attr , html_options )
92+ number_field ( attr , ** html_options )
9493 end
9594
96- def float_field ( attr , html_options = { } )
95+ def float_field ( attr , ** html_options )
9796 html_options [ :step ] ||= 'any'
98- number_field ( attr , html_options )
97+ number_field ( attr , ** html_options )
9998 end
10099
101- def decimal_field ( attr , html_options = { } )
100+ def decimal_field ( attr , ** html_options )
102101 html_options [ :step ] ||=
103102 ( 10 **-column_property ( object , attr , :scale ) ) . to_f
104- number_field ( attr , html_options )
103+ number_field ( attr , ** html_options )
105104 end
106105
107106 # Customize the standard text area to have 5 rows by default.
108- def text_area ( attr , html_options = { } )
107+ def text_area ( attr , ** html_options )
109108 add_css_class ( html_options , 'form-control' )
110109 html_options [ :rows ] ||= 5
111- super ( attr , html_options )
110+ super ( attr , ** html_options )
112111 end
113112
114113 # Render a select element for a :belongs_to association defined by attr.
115114 # Use additional html_options for the select element.
116115 # To pass a custom element list, specify the list with the :list key or
117116 # define an instance variable with the pluralized name of the
118117 # association.
119- def belongs_to_field ( attr , html_options = { } )
120- list = association_entries ( attr , html_options ) . to_a
118+ def belongs_to_field ( attr , ** html_options )
119+ list = association_entries ( attr , ** html_options ) . to_a
121120 if list . present?
122121 add_css_class ( html_options , 'form-control' )
123122 collection_select ( attr , list , :id , :to_s ,
124- select_options ( attr , html_options ) ,
125- html_options )
123+ select_options ( attr , ** html_options ) ,
124+ ** html_options )
126125 else
127126 # rubocop:disable Rails/OutputSafety
128127 none = ta ( :none_available , association ( @object , attr ) ) . html_safe
@@ -139,10 +138,10 @@ def belongs_to_field(attr, html_options = {})
139138 # To pass a custom element list, specify the list with the :list key or
140139 # define an instance variable with the pluralized name of the
141140 # association.
142- def has_many_field ( attr , html_options = { } )
141+ def has_many_field ( attr , ** html_options )
143142 html_options [ :multiple ] = true
144143 add_css_class ( html_options , 'multiselect' )
145- belongs_to_field ( attr , html_options )
144+ belongs_to_field ( attr , ** html_options )
146145 end
147146 # rubocop:enable Naming/PredicateName
148147
@@ -194,7 +193,7 @@ def cancel_link(url = nil)
194193
195194 # Depending if the given attribute must be present, return
196195 # only an initial selection prompt or a blank option, respectively.
197- def select_options ( attr , options = { } )
196+ def select_options ( attr , ** options )
198197 prompt = options . delete ( :prompt )
199198 blank = options . delete ( :include_blank )
200199 if options [ :multiple ]
@@ -238,7 +237,7 @@ def labeled(attr, content = {}, options = {}, &block)
238237 options = content
239238 content = capture ( &block )
240239 end
241- control = control_class . new ( self , attr , options )
240+ control = control_class . new ( self , attr , ** options )
242241 control . render_labeled ( content )
243242 end
244243
@@ -275,18 +274,17 @@ def labeled_field_method?(name)
275274
276275 # Renders the corresponding field together with a label, required mark
277276 # and an optional help block.
278- def build_labeled_field ( field_method , *args )
279- options = args . extract_options!
277+ def build_labeled_field ( field_method , *args , **options )
280278 options [ :field_method ] = field_method
281- control_class . new ( self , *( args << options ) ) . render_labeled
279+ control_class . new ( self , *args , ** options ) . render_labeled
282280 end
283281
284282 # Returns the list of association entries, either from options[:list] or
285283 # the instance variable with the pluralized association name.
286284 # Otherwise, if the association defines a #options_list or #list scope,
287285 # this is used to load the entries.
288286 # As a last resort, all entries from the association class are returned.
289- def association_entries ( attr , options )
287+ def association_entries ( attr , ** options )
290288 list = options . delete ( :list )
291289 unless list
292290 assoc = association ( @object , attr )
0 commit comments