From aaa9162c13ac4f0823c07dd69830d389e890d2b3 Mon Sep 17 00:00:00 2001 From: Eric Boehs Date: Thu, 26 Apr 2012 12:11:49 -0400 Subject: [PATCH] Allowing label to be added to multiparam fields --- lib/meta_search/helpers/form_builder.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/meta_search/helpers/form_builder.rb b/lib/meta_search/helpers/form_builder.rb index 944da5e..8f911cc 100644 --- a/lib/meta_search/helpers/form_builder.rb +++ b/lib/meta_search/helpers/form_builder.rb @@ -42,17 +42,20 @@ def multiparameter_field(method, *args) defaults = has_multiparameter_defaults?(args) ? args.pop : {} raise ArgumentError, "No multiparameter fields specified" if args.blank? html = ''.html_safe + fields_count = 0 args.each_with_index do |field, index| type = field.delete(:field_type) || raise(ArgumentError, "No :field_type specified.") cast = field.delete(:type_cast) || '' opts = defaults.merge(field) + field_name = opts[:name] || method.to_s + "(#{fields_count + 1}#{cast})" html.safe_concat( @template.send( type.to_s, @object_name, - (method.to_s + "(#{index + 1}#{cast})"), + field_name, objectify_options(opts)) ) + fields_count += 1 unless type == :label end html end @@ -163,4 +166,4 @@ def has_multiparameter_defaults?(args) end end end -end \ No newline at end of file +end