I’m close to getting this to work, but not quite there. I’m trying to
implement a dropdown control, with the current choice selected.
I have the following code in the view:
5 <select id="product_product_type" name="product[product_type]">
6 <%=
7 types = ProductType.find(:all, :order => "product_type")
8 options_from_collection_for_select( types, :id, :product_type,
selected=@product_type_id)
9 %>
10 </select
Which renders the following:
Product type
...
Supplies
However, in the browser the “Supplies” item isn’t displaed on load, but
the blank first option is. Anyone see what I’m doing wrong?
Joe,
I found this thread on another list, I’m working on it now…I’ll let
you know
if I come up with a working solution.
http://wrath.rubyonrails.org/pipermail/rails/2005-January/001905.html
jschairb wrote:
Joe,
I found this thread on another list, I’m working on it now…I’ll let
you know
if I come up with a working solution.
http://wrath.rubyonrails.org/pipermail/rails/2005-January/001905.html
This works, it’s probably not the best implementation…but it works.
http://wiki.rubyonrails.com/rails/pages/HowtoUseFormOptionHelpers
look for the section called ‘A collection_select like helper’ I copied
that code into application_helper.rb and then used his view
implementation. Worked for me, although I had to change the last part
in the view from :
@page.section_id
to just
page.section_id
Hopefully this will get you going. Later.
Try this:
<%= collection_select(:product, :product_type, types, :id,
:product_type, { :include_blank => true }) %>
It works fine for me.
SandroDS
On 12/15/05, Joe E. [email protected] wrote:
10 </select
However, in the browser the “Supplies” item isn’t displaed on load, but
the blank first option is. Anyone see what I’m doing wrong?
–
Posted via http://www.ruby-forum.com/.
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Sandro Duarte
Analista de Sistemas
TRE-RS/SI