At the moment I have the following code:
<% form_for :query, :url => {:action => ''plot''} do
|form| %>
<p>
<label for "query_product_name"> Product: </label>
<%= form.select :product_name,
@products,
:prompt => "Select Product"
%>
</p>
<%=submit_tag "Display Results", :class =>
"submit"%>
<%end%>
This enables me to select a single product from a drop down menu of
products.
It then saves this product in query object.
I want to be able to select multiple products and for them to be held as
an array in query.
Is this possible??
Chris.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
Chris Finch wrote:> At the moment I have the following code: > > > <% form_for :query, :url => {:action => ''plot''} do |form| %> > > <p> > <label for "query_product_name"> Product: </label> > <%= form.select :product_name, > @products, > :prompt => "Select Product" > %> > </p> > > <%=submit_tag "Display Results", :class => "submit"%> > > <%end%> > > This enables me to select a single product from a drop down menu of > products. > It then saves this product in query object. > > I want to be able to select multiple products and for them to be held as > an array in query. > > Is this possible?? > > Chris. > > -- > Posted via http://www.ruby-forum.com/.Add '':multiple=>true'' to the options hash for the select _Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
o.k. so I added '':multiple=>true'' in the following way:
<% form_for :query, :url => {:action => ''plot''} do
|form| %>
<p>
<label for "query_product_name"> Product: </label>
<%= form.select :product_name,
@products,
:prompt => "Select Product",
:multiple => true
%>
</p>
<%=submit_tag "Display Results", :class =>
"submit"%>
<%end%>
but it is still just a combo box that only lets me select one item.
Any other ideas?
Chris
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
try doing this..
form.select :product_name, @products, {:prompt=>''select
product''},
{:multiple=>true}
_Kevin
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
that''s worked - Brilliant. Thanks very much -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I haven''t got it to work quite yet. When I select multiple products, I was hoping they would be sent as an array to the query object. But: When I select multiple products, only 1 product (the first one) gets sent. Do you know how to send them as an array? Chris -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris Finch wrote:> I haven''t got it to work quite yet. > > When I select multiple products, I was hoping they would be sent as an > array to the query object. > > But: > > When I select multiple products, only 1 product (the first one) gets > sent. > > Do you know how to send them as an array? > > Chris > > > -- > Posted via http://www.ruby-forum.com/.Give the control a name like :name=>''products[]'' put that in the second hash with the :multiple=>true _Kevin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Nothing seems to work - could you be more specific? Chris. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Chris, here is something I have:
FORM:
<p>
<label for="categories">Categories</label><br />
<select id="categories" name="categories[]"
multiple="multiple"
size="10" style="width: 250px;">
<%= options_from_collection_for_select(@all_categories,
:id, :long_name,
@selected) %>
</select>
</p>
CONTROLLER:
def create
@photo = Photo.new(params[:photo])
@photo.categories = Category.find(params[:categories]) if
params[:categories]
if @photo.save
flash[:notice] = ''Photo was successfully created.''
redirect_to :action => ''list''
else
@all_categories = Category.find(:all, :order =>
''name'')
render :action => ''new''
end
end
Hope that helps some.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---
I''m sorry but I''m still puzzled!
I just can''t get the form when submitted to be able to hold multiple
products.
<% form_for :query, :url => {:action => ''plot''} do
|form| %>
<p>
<label for "query_product_name"> Product: </label>
<%= form.select :product_name,
@products,
{:prompt => "Select Product"},
{:multiple => true}
%>
</p>
What am I doing wrong?
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---