From f6f4de9fdef5e7c2ae1c727debddc66adab927c6 Mon Sep 17 00:00:00 2001 From: Aleksander Smywinski-Pohl Date: Wed, 3 Feb 2016 10:34:41 +0100 Subject: [PATCH] Name for the visible field and defaults changes --- lib/simple_form/inputs/autocomplete_input.rb | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/simple_form/inputs/autocomplete_input.rb b/lib/simple_form/inputs/autocomplete_input.rb index 63f493a..2f7663d 100644 --- a/lib/simple_form/inputs/autocomplete_input.rb +++ b/lib/simple_form/inputs/autocomplete_input.rb @@ -14,7 +14,7 @@ def input(wrapper_options = nil) def input_html_options super.deep_merge( - name: '', + name: "#{object_name}[#{attribute_name }_label]", id: options.key?(:input_html) && options[:input_html].key?(:id) ? options[:input_html][:id] : input_tag_id, value: options.key?(:value) ? options[:value] : input_tag_value, data: { source: options[:source] } @@ -41,13 +41,18 @@ def input_tag_value elsif association.respond_to?(:name) association.name else - warn "#{association.class} must respond to label, title, or name" - nil + association.to_s end end def hidden_tag_value - association.id if association + if association + if respond_to?(:id) + association.id + else + association.to_s + end + end end def sanitized_object_name