Displaying 20 results from an estimated 104 matches for "options_for_select".
2006 Jan 23
2
problem with options_for_select
Hi All,
I am having a little difficulty using the options_for_select forms
helper method. I have a form for an active record object book, which
belongs to a publisher. Using the options_for_select is working fine
as far as creating the various options, but it will not output the
"selected=''selected''" bit of html needed to identify...
2007 May 11
5
options_for_select - how to set the selected value?
...lect_tag with 4 values pulled in via a helper:
def filter_hours
filter_hours = [
["1 hour", 1],
["24 hours", 24],
["7 days", 168],
["14 days", 336],
]
end
The select_tag looks like the following:
select_tag :order_hours, options_for_select(filter_hours, :selected =>
@selected_order_hours)
@selected_order_hours is being set in the controller when the form is
posted. It comes back as either 1, 24, 168, 336 and is definitely
being set as confirmed through logging and printing from the view.
However, the selected valued is never set...
2008 Jul 20
1
selected attribute in options_for_select
Hello Everyone
I have a select_tag which I populate using a map, I use
options_for_select method to pass the map and "selected" value. For some
reason I can not get the option "selected" based on the value I pass to
the selected attribute. Here is the code
<%= select_tag :current_course,
options_for_select( Course.find(:all).map {|p| [p.title,p.id]},
@se...
2009 May 27
9
Contingent Select Boxes - 2 Q's
I have a form with contingent select boxes (the state is contingent on
the country selected, so when the country selected changes, the state
changes -- I am using the Carmen plugin for getting my state names and
country names together, but not the functionality I am interested in
achieving).
Everything works fine except I cannot figure out how to amend my code
such that:
A. When the form is first
2011 Jan 08
9
options_for_select.
Even reading the documentation I can not figure out what is the
select_tag difference between this:
<% = select_tag (bags [], "options_for_select (bags.collect @ {| bb |
[bb.bag_type, bb.id]},
ruser.bags.collect @ {| ub | ub.id}), {: multiple => true,: id =>
"bags"})%>
and this:
<% = select_tag "bags [], " options_for_select (bags.collect @ {| bb |
[bb.bag_type, bb.id]},
: multiple => tr...
2007 May 24
1
How do I show the selected values in options_for_select? Not as simple as it sounds.
How do I show the selected values in options_for_select? I have a
Service model and a AccessControl model. When a user edits a Service I
want the services access_controls to be pre-selected.
Models:
Service has_many AccessControls
AccessControl belongs_to Service
application.rb:
$types = Array["Athens", "htpasswd", "IP",...
2006 Jul 04
1
options_for_select - default nil value
I have a field in a view, like so:
<%= select_tag(''quoted_condition'',
options_for_select([''NEW'',''RETAIL'',''OEM'',''REFURB''], ''NEW'')) %>
This sets the ''selected'' value to ''NEW'' - however, I would like to have
a nil value here, so I can "force" the use...
2008 Jan 03
1
Help using options_for_select in select_tag
<b>Client</b><br />
<%= select_tag ''clients[]'',
options_for_select(
[['' '',''1''], [''aaaa'',''2''],
[''daemon'',''3''],[''nortel'',''4''],[''telefonica'',''5''],[''local'',''6&...
2006 Jul 13
2
Simple dropdown menu
Hi, I''m quite new to this language and I''m having trouble finding out
simple things like a dropdown menu in rhtml. I know I have to use <%
select_tag %> but I''ve read lots of different ways to put in the options
so I''m a bit confused. Options are hard-coded for the menu I''m trying to
create so no database is involved!
Thanks v much!
Bex
--
2007 May 24
3
Help with Create and Update with options_for_select in a select_tag
I have a select_tag in my view that uses options_for_select with
multiple = true. I am having trouble figuring out the Rails way to
create and update that field. Please help.
Models:
-------------
Service has_many AccessControl
AccessControl belongs_to Service
application.rb
-------------------------
$types = Array["Athens", "htpasswd"...
2006 Jan 14
2
I think options_for_select is backwards
With a hash such as:
stuff = {''1''=>''desc 1'', ''2''=>''desc 2'', ''3''=>''desc 3''}
options_for_select(stuff) will output:
<option id="desc 1">1</option>
<option id="desc 2">2</option>
<option id="desc 3">3</option>
Doesn''t this seem backwards? Hash keys correspond to
ids, and should be used for option ids IMO.
BTW, is the...
2007 May 10
0
options_for_select helper is also mess....
I am ''trying'' to use ''options_for_select''
<select name="selected_distance" id="selected_distance"
style="width:8%;">
<%= options_for_select(["2", "5", "10", "15", "25" ], @selected_distance
) %>
</select>
which generates the html.....
2007 May 21
0
options_for_select and setting css class values
...is possible using erb (at the very least, I can''t
figure it out by googling or via searching this board), so here
goes...
i''m using erb to make a select box with several hundred <option>
values
it looks something like this:
<%= select_tag ''controls'', options_for_select(@controls.map {|cpd|
["#{cpd.compound_name}.....#{cpd.trimmed_number}"]}), {:class =>
''superwide'', :size => 20} %>
the above code works great...except for 1 thing.
i''d like to cycle the color of every other <option> tag using css.
obviously, i...
2008 Jan 22
1
getting multiple select to work: options_for_select
Hi,
<%= select_tag ''image_id'', options_for_select(Image.find(:all) {|
an_image| [ an_image.name, an_image.id ] }), :multiple => true %></p>
* I am in a view, and I am trying to search the image table and make a
multiple select box with each image''s name.
* Right now it is working, but I see this:
----------------------------...
2010 Jun 17
1
Problem with options_for_select
Hi,
I have a problem with the form select. In the value field I have the
generated html...
<%= f.select :brand_id,
options_for_select([[''Brands'', 0]] +
@search_brands.map { |b| [b.name, b.id]}),
{:id => ''cbxBrand'', :tabindex => (@tabindex += 1)} %>
This is the html:
<select name="search[brand_id]" id="search_brand_id">
<option value=&quo...
2006 Feb 02
8
How to get all selected rows in the mutli-selection listbox?
Hi,
I have created a multiple selection listbox with
rails, when I try to get the rows selected by user,
rails send back only the first one, how can I get the
other selected rows????
I created the listbox with the following function:
select_tag("form__list1",
options_for_select(["A","B","C","D"], selected = "A"),
html_options = {"size" => 5, "multiple" => true})
What I get from params is :
!map:HashWithIndifferentAccess
commit: Next
action: index
controller: cellfiles
form__list1: "A"...
2006 Jun 26
0
options_for_select-how to store cookie selected value ques.
...e
cookies[:state] = state
end
if !cookies[:state].blank?
@default_state = cookies[:state]
else
@default_state = ""
end
# view - html
State:
<td><%= select_tag "stateid",
options_for_select(@state_names, :selected => @default_state) %></td>
SOURCE OF HTML
<td>State</td>
*** I WANT THE VALUE IN THE State value="5.0" as the cookie.
<td><select id="stateid" name="stateid">
<option value=&quo...
2006 Mar 08
1
question about options_for_select array
Hi!
If i have something like this used to create select tag:
options = [["Dollar", "$"], ["Kroner", "DKK"]]
and later read value from the database and get "DKK", what is the
easiest way to get "Kroner" value?
--
Posted via http://www.ruby-forum.com/.
2010 Mar 24
0
Select_tag with options_for_select not populating DB.
...I changed variables and instances for privacy reasons(I''m sure most
people do.)
<% form_for :animals do |f| %>
<%= f.error_messages %>
<%= f.label :update %>
<br />
<%= f.text_area :updates, :rows => 6 %>
<br />
<%= select_tag "update", options_for_select(%w{dogs_info
feline_info}) %>
<%= f.submit "submit" %>
<% end %>
I really appreciate any help!
Thank you.
--
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-...
2006 Mar 16
4
calling an actionview method from inside a model
Hi,
I would like my model instance to produce it''s own list of options for
a form select. This is from a product model that has_many variations
def alts_for_select(current_id)
the_map = variations.map{|v| [v.name, v.id]}
options_for_select(the_map, current_id)
end
the model cannot see the options_for_select method
I tried to use
ActionView::Helpers::FormOptionsHelper::options_for_select(the_map, current_id)
but this didn''t work.
Any ideas?
Thanks,
Peter