Hi All,
Just got the latest version v1.5.1_rc1 (was working with v1.5.0_rc0
till now) and I noticed lots of errors on formulas.
I think there is a bug with Form.serialize().
This is output of my $_POST and you can see here, index "airline_logo"
is present, however empty.
Array
(
[airline_id] =>
[airline_name] => name
[airline_logo] =>
[submit] => Save
[airline_text] => txt
)
When I run it again with latest rc1 I am getting the array which looks
like this:
Array
(
[airline_id] =>
[airline_name] => name
[submit] => Save
[airline_text] => txt
)
As you''ve noticed, the "airline_logo" is not present in that
array.
In a prototype version 1.5.0, code looks like this:
if (value != undefined) {
if (result[key]) {
if (result[key].constructor != Array) result[key] [result[key]];
result[key].push(value);
}
else result[key] = value;
}
In the latest prototype.js, line 2542, you can see:
if (value != null) {
if (key in result) {
if (result[key].constructor != Array) result[key] [result[key]];
result[key].push(value);
}
else result[key] = value;
}
The reason for the non existant array keys, when value is empty, is
line 2542
if (value != null) {
My guess is, that you wanted to save some space, and do not send empty
values?
Is this is rather a feature then a actual bug, is there a way I can
overwrite Form.serialize() by extending Form object? (Sorry for maybe
stupid questions but I am still new to prototype).
I really need these array keys to be present in the $_POST, though
they are empty.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
yea i believe it should be:
if (value !== null) {
not
if (value != null) {
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Colin Mollenhour
2007-Mar-15 23:02 UTC
Re: Form.serialize() behavior: bug or feature ? (1.5.1_rc1)
This is probably due to the oh so verbose and muddled rewrite of Hash.toQueryString in 1.5.1. See this thread: http://groups.google.com/group/prototype-core/browse_frm/thread/140fdf88eed057d I''ve been fighting tooth and nail for us PHP developers but to no avail thus far. I suggest you use my rewrite of Hash.toQueryString available here: http://colin.mollenhour.com/posttest.php (Click "(code)" and paste that into a js file that is included after prototype.js.) or simply go back to 1.5.0. The updated $$ sure is nice though... Colin aLEczapKA wrote:> Hi All, > > Just got the latest version v1.5.1_rc1 (was working with v1.5.0_rc0 > till now) and I noticed lots of errors on formulas. > I think there is a bug with Form.serialize(). > > This is output of my $_POST and you can see here, index "airline_logo" > is present, however empty. > > Array > ( > [airline_id] => > [airline_name] => name > [airline_logo] => > [submit] => Save > [airline_text] => txt > ) > > When I run it again with latest rc1 I am getting the array which looks > like this: > > Array > ( > [airline_id] => > [airline_name] => name > [submit] => Save > [airline_text] => txt > ) > > > As you''ve noticed, the "airline_logo" is not present in that array. > > In a prototype version 1.5.0, code looks like this: > > if (value != undefined) { > if (result[key]) { > if (result[key].constructor != Array) result[key] > [result[key]]; > result[key].push(value); > } > else result[key] = value; > } > > In the latest prototype.js, line 2542, you can see: > > if (value != null) { > if (key in result) { > if (result[key].constructor != Array) result[key] > [result[key]]; > result[key].push(value); > } > else result[key] = value; > } > > > > The reason for the non existant array keys, when value is empty, is > line 2542 > if (value != null) { > > > > My guess is, that you wanted to save some space, and do not send empty > values? > > Is this is rather a feature then a actual bug, is there a way I can > overwrite Form.serialize() by extending Form object? (Sorry for maybe > stupid questions but I am still new to prototype). > > I really need these array keys to be present in the $_POST, though > they are empty. > > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---