This works except for one thing…if there’s a value in
placement.client_slot_id, it doesn’t ‘select’ the value in the selection
list. How can I get it to select the value that matches
@placement.client_slot_id.name ?
view
<%= select_tag ‘placement’, ‘client_slot_id’,
:selected => @placement.client_slot.name %>
<%= observe_field(
:placement_facility_id,
:frequency => 0.5,
:update => :client_slot_id,
:url => { :controller => 'placements',
:action => :lookup_client_slot },
:with => "'facility_id='+escape(value)") %>
controller
def lookup_client_slot
@client_slots = ClientSlot.find(:all,
:conditions => [“facility_id = ?”, params[:facility_id]]
).collect {|fac| [fac.name, fac.id]}
render :inline => “<%= select ‘placement’,
‘client_slot_id’, @client_slots %>”
end
–
Craig W. [email protected]
Craig W. wrote:
<%= select_tag 'placement', 'client_slot_id',
:selected => @placement.client_slot.name %></span>
According to the docs, select_tag takes the object and a string
containing the actual text blah.
You may want to look at collection_select instead.
Alan
On Wed, 2006-12-20 at 10:57 +0100, Alan F. wrote:
ActionView::Helpers::FormOptionsHelper
I promise that I wouldn’t have posted my question if I hadn’t gone over
and over these api pages and still clanking my head against the wall. I
have used options and collections in quite a few different areas of this
web application but never in this manner.
The issue that I am having is that I am able to return the proper
selection list via controller code rendered inline but no matter what I
try, I can’t get it to match up the current value as the ‘selected’ item
in the selection list itself.
I do notice though, that by having my view code like this…
<%= select_tag(‘placement’, ‘client_slot_id’,
options = {:selected => @placement.client_slot_id}) %>
that it results in queer html…
client_slot_id
because both the select id and name are placement whereas view code…
<%= options = [[“Accepted?”, “” ]] + ApplicationHelper::YES_NO
select(“placement”, “accepted”, options) %>
results in…
Accepted?
Yes
No
Craig
–
Craig W. [email protected]