submit input to params

I have a form for a model, that has an auto-fill button based on
existing record. Basically you can choose if to duplicate an existing
record using a select list of the record already in the db.

This select list is inside the form for the new model, but I need to
somehow submit it in an independent manner from the rest of the form. I
was able to do this with observe_field, but I want to do it using a
button or link:

<% form_for @product, :url => { :action => 'create' } do -%>

<%= collection_select :product, :id, Product.find(:all), :id, :name %>
<%= link_to 'fill form', :url => { :action => 'fill_form' } %>

# product fields

<% end %>

I'm having trouble catching the actual selection in the params[], and
I'd really appreciate help on this - thanks.

I used link_to_remote with the :submit option pointing to the parent of
the input I want to submit (doesn't have to be a form!).

<% form_for ... do |f| %>
  <span id="inside_form">
    <%= collection_select ... %>
    <%= link_to_remote... :submit => 'inside_form' %>
  </span>

  # rest of form fields
<% end %>

Hope this helps someone :slight_smile: