CJWheels
CJWheels

Reputation: 1

Submitting multiple attributes to controller from collection select in form

I want a collection select tag in rails to submit two attributes of the chosen item to the controller when the form is submitted. Basically, I have a list of counties and I want to submit both the county and the state as parameters. No problem having it submit one or the other, but not both. Am I thinking about this the wrong way? Here's what I have so far...

<%= form_tag(plans_path, method: 'get', action: 'screen2') do %>
    <%= text_field_tag :ZIP, "ZIP Code", id: "zipBlur"%>

    <%= collection_select(nil, :county, @counties.order('RES_RATIO DESC'), :COUNTY, :COUNTY_NAME, {:selected => "#{params[:county]}"}) %>

    <%= submit_tag 'Screen', :name=> nil %> 

<% end %>

Thanks for your help!

Upvotes: 0

Views: 75

Answers (1)

Quang Anh Ho
Quang Anh Ho

Reputation: 11

using :multiple => true

ex:

<%= collection_select(:ingredient, :supplier_ids, 
              Supplier.all(:order=>"name ASC"), 
              :id, :name, {:selected => @ingredient.supplier_ids, :include_blank => true}, {:multiple => true}) %>

Upvotes: 1

Related Questions