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