Working on an odd one here. I''ve got a simple scaffold that for some
reason doesn''t catch the correct data back on boolean fields.
That''s
to say that every time I load the page, every single true/false menu
option is set to false.
The scaffold generated the following for the boolean fields in the
_form.rhtml file:
<p><label
for="consultant_active">Active</label><br/>
<select id="consultant_active"
name="consultant[active]"><option
value="false">False</option><option
value="true">True</option></
select></p>
It''s completely inert html with no possibility of pulling in the
current field value so it makes sense that it''s not truly interactive.
If I select True, it does get correctly passed back and written to
the database, but if I don''t touch it, the false value gets written
to the database. So I thought that it would be more intelligent if
these options were presented as radio buttons and see if I couldn''t
replace the html with some code.
I''ve tried a number of variations, and according to the documentation
at http://edgedocs.planetargon.org/ I should do this:
radio_button(object_name, method, tag_value, options = {})
Returns a radio button tag for accessing a specified attribute
(identified by method) on an object assigned to the template
(identified by object). If the current value of method is tag_value
the radio button will be checked. Additional options on the input tag
can be passed as a hash with options. Example (call, result). Imagine
that @post.category returns "rails":
radio_button("post", "category", "rails")
radio_button("post", "category", "java")
<input type="radio" id="post_category"
name="post[category]"
value="rails" checked="checked" />
<input type="radio" id="post_category"
name="post[category]"
value="java" />
However, when I supply
<%= radio_button("consultant","active","True")
%>
<%= radio_button("consultant","active","False")
%>
I get:
<input id="consultant_active_true"
name="consultant[active]"
type="radio" value="True" />
<input id="consultant_active_false"
name="consultant[active]"
type="radio" value="False" />
which doesn''t match the documentation. And more importantly, it
doesn''t work :-)
The environment is:
- ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-darwin8.9.1]
- Rails 1.2.3
Can anyone shed some light on this behaviour?
Erik
--~--~---------~--~----~------------~-------~--~----~
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?hl=en
-~----------~----~----~----~------~----~------~--~---