Displaying 20 results from an estimated 7000 matches similar to: "selected_value or select not work"
2006 Jun 10
4
collection_select question
How do I specify which option should be initially selected when using
the collection_select command? I''ve tried:
collection_select(:selectionfilter, :producer_id, Producer.find(:all),
:id, :name, {:include_blank => true, :selected_value =>
@initial_selection})
However it doesn''t return the desired results (the option with the value
of @initial_selection selected).
2005 Oct 26
1
Re: collection_select question about selected_value
Paul Welty wrote:
> collection_select(:client, :company_id, @companies, :id, :name, {
> :selected_value => 2 , :prompt => "Please select a company..." })
>
> Returns a functioning SELECT element, but it won¹t select the second item.
> (BTW, using the selected_value as a string doesn¹t work either)
>
> Am I doing something wrong, or is this impossible?
>
2006 Nov 28
2
collection_select and selected_value
Hi,
I am using collection_select to build a drop down list. I would like
to have the current value selected. How can I do that?
My current code is straight from the example in Pragmatic Programmers
book [2nd ed, p480] copying here for reference.
<%=
@users = User.find(:all, :order => "name" )
form.collection_select(:name, @users, :id, :name)
%>
I went through the api docs
2006 Aug 17
1
2 newbie question
Hey all,
I have 2 newbie questions,
1st question:
<%= collection_select (:region, :id, @regionall, :id,
:title,options={:prompt=>"- Select cat -"}) %>
Ignores the :prompt part while options={:include_blank => true} works.
Any idea what I?m doing work with :prompt ?
2nd question:
How can make my collection_selected to display it''s third key by default?
I know it has
2011 May 17
0
Select not maintaining state on nested form with
I am using nested forms with multiple instances of various of the forms. The
problem I cant figure out is how to maintain state for the select between
postbacks. I am using ''options_from_collection_for_select'' and in this the
last param is to be the selected value, but given the dynamic nature, the
value is going to depend on the iteration of the form builder. If I manually
force
2006 Jul 02
0
Problem with select, options_from_collection_for_select for selected items
I''m having problems to make the selected works, i''ve been trying with select
and options_from_collection_for_select.
I''ve tried, :selected, :selected_key, :selected_value, and all i can got
from the doc page (
http://rubyonrails.org/api/classes/ActionView/Helpers/FormOptionsHelper.html#M000399
)
and from wiki.
Code:
select(''informacao'',
2006 May 15
0
collection_select and API docs questions
Hello,
I''m wondering where in the docs am I suppose to find a complete list of
options for the collection_select helper?
For instance the API docs have an example for the select helper as
below:
select("post", "person_id", Person.find_all.collect {|p| [ p.name,
p.id ] }, { :include_blank => true })
Where the heck do I find valid values for the options and
2006 Jul 20
0
Getting joined collections on a form
Greetings, I''m looking for suggestions on how to simplify getting customer
addresses on a form:
I''m jumping between controller and view several times; alternating between
rhtml and rjs, in order to display customers and their addresses on an
invoicing form. It''s very messy.
I have a one to many relationship between Customer and Addresses, each
customer has one or more
2006 Jul 21
0
Selecting customers and addresses in a form (was Getting joined collections on a form)
(Sorry if you have received this twice, I''m having trouble sending mail to
the rails list)
Greetings, I''m looking for suggestions on how to simplify getting customer
addresses on a form:
I''m jumping between controller and view several times; alternating between
rhtml and rjs, in order to display customers and their addresses on an
invoicing form. It''s very
2009 Jan 08
4
Problem with disable_with
Hi Group,
I have a registration.html.erb page with the following JavaScript at
the top which I use to validate form fields:
<script type="text/javascript">
<!--
function validate(){
if ((document.myForm.email_projectname.value=="")||
(document.myForm.email_projecttype_id.selectedIndex<1)||
(document.myForm.email_region_id.selectedIndex<1))
{
alert
2010 Feb 22
3
Rails 2.3.5/Ruby1.8.7 Collection_Select Labels with ampersands "&"
I am having an annoying problem displaying the labels of a select box
correctly where there is an ampersand contained within the label
string.
On a form being rendered with the form_for helper the
collection_select reads data from a Mysql 5.075 database the text
stored in the database is "Surabaya & Surrounding Areas" when rendered
and displayed in firefox 3.6 or safari is is
2007 Dec 22
3
collection_select validation problem
I''m trying to assign a parent foreign key value using
collection_select from my child "new" form. The problem I''m having is
if I do not make a selection, I get the following error instead of the
Rails validates_presence_of error:
You have a nil object when you didn''t expect it!
You might have expected an instance of Array.
The error occurred while evaluating
2009 Aug 14
0
country select with i18n
I am trying to manage the country names with i18n. I have a countries
table with the countries extension codes (us., co., ve., .bo. etc...)
and the yml files with their complete names:
en:
countries:
ar: Argentina
co: Colombia
.
I am trying to make a form with a select option for country and came
up with this:
<%= f.select("country_id", Country.all.collect {|p| [ t
2012 Aug 16
6
undefined method `with_indifferent_access' for "":String
Hi
I''m having a issue with one object when try to update the attributes in
this object previously saved in the database
I have one object comp and one object reg they have this relationship
comp
has_many regs
reg
belongs_to comp
when run use the method valid? like this
current_contribuyente.comps.build(params[:comp]).valid?
it returns: IndexError (string not matched)
And when
2010 Jan 28
1
validates preference of at least one param
I have a simple RESTful search scaffold that finds data in a separate
model and controller.
[code]
<h1>New search</h1>
<% form_for(@search) do |f| %>
<%= f.error_messages %>
<p>
<%= f.label :category_id %><br />
<%= f.collection_select :category_id, Category.all, :id, :name,
:include_blank => true %>
</p>
<p>
Age
2006 Jan 25
1
Collection_select ?
In case where a collection_select is selecting a required value for an
object (a not null field), is it possible to set a generic default value
for the select box? I have tried :prompt => true and :include_blank =>
true but neither changes the value for required fields. It does for
non-required fields though.
Thanks.
Nathan Mealey
Operations Director
Northeast Region
Pilgrim IT,
2007 Jan 11
4
collection_select - how to set selected options?
In a form, I am trying to use collection_select with multiple=true, like
so:
collection_select(:user, :roles, Role.find(:all), ''id'', ''name'', {},
:multiple => true) %>
My multiple select box is rendered fine, but...
I want the select to have the current role options for the user
pre-selected when I view it. So if there are five roles in the database
and
2009 Mar 02
0
Implementing conditional read-only attributes of ActiveRecord objects
Hello,
my goal is to implement the option of specifying a condition in
attr_protected, attr_readonly and possibly other attribute methods in
ActiveRecord objects.
Rationale (example):
class User < AR:Base
# User should not be able to modify fields any more once they have
been verified
attr_readonly :firstname, :lastname, :gender_id, :birthdate, :if
=> :passport_verified?
# ...
end
2006 Jul 28
3
Forms: handle foreign keys (AssociationTypeMismatch)
Hi all
I tried and tried and tried, but I still fail in creating a form with
proper validation and stuff for foreign keys... So I''d really like to
get some help here.
I''m creating a booking site for DJ''s, and for every booking one can
choose one of different countries:
class Booking < ActiveRecord::Base
validates_presence_of :country_id
2006 Jul 16
6
using collection_select
hello,
supposing i have a User class that contains a Wibble
class User < ActiveRecord::Base
has_one :wibble
end
in my view i have
<%= collection_select :user, :wibble, Wibble.find(:all), :id, :name %>
when i post, i get an error like
"Wibble expected, got String"
how/where am I supposed to convert this posted wibble_id into a
Wibble, or am I using collection_select