Prototype 1.5.0_rc0 form_serialize issues for select lists


we have a rails 1.0 application and I did some tests to see if we could
to rails 1.1

One issue I found, is that prototype 1.5.0_rc0, that was installed by
rails:update:javascripts, changes the way a select list is serialized if
option has an empty value.

Consider a form like
<%= form_tag :action => ‘test_form_post’ %>
<% options = { ‘’ => ‘select’, ‘1’ => ‘one’, ‘2’ => ‘two’ } %>
<%= select_tag(“test”, options.keys.collect { | key | “#{options[key]}” }.join() ) %> <%= submit_tag
“send” %>
<%= end_form_tag %>

which is rendered to

select one two as expected.

The idea is to present the entry ‘select’ initially to indicate that the
should select an option. In case he does not, an empty value is
returned, which
fails in a validates_presence_of validation.

This works for normal forms and for remote forms using rails 1.0 /
1.4. In both cases I get a parameter hash
{“commit”=>“send”, “action”=>“test_form_post”, “controller”=>“develop”,
Unfortunately rails 1.1 / prototype 1.5.0_rc0 provides
{“commit”=>“send”, “action”=>“test_form_post”, “controller”=>“develop”,
“test”=>“select”} for a remote form.
Instead of the empty value the content of the option is returned.

I think this would be ok, if there wasn’t a value attribute at all (in
that case
form submission would output the content as well).

Is this difference between normal form submission and remote forms
It was one of the great features that prototype allows me to switch from
to remote forms without having to change anything in the handling of the

If it is intentional: how should my use case be implemented?
I want to have a labelled option entry, that indicates, that the user
make a choice (‘select’ is just the label I choose for the test case).
But I don’t want to deal with that label in the application.
Of course I could use some illegal value like -1 in the app and do some
treatment. But that implies extra code in the contoller or model.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs