Permalink
Browse files

Fixed bug #1384 for the hash accumulator + test case.

  • Loading branch information...
1 parent 24414bf commit e6c89d238d625642b641070b371c5d1aa335e264 Jorgen Rydenius committed Sep 20, 2012
Showing with 12 additions and 5 deletions.
  1. +1 −1 src/prototype/dom/form.js
  2. +2 −1 test/unit/fixtures/form.html
  3. +9 −3 test/unit/form_test.js
@@ -113,7 +113,7 @@ var Form = {
accumulator = function(result, key, value) {
if (key in result) {
if (!Object.isArray(result[key])) result[key] = [result[key]];
- result[key].push(value);
+ result[key] = result[key].concat(value);
} else result[key] = value;
return result;
};
@@ -128,7 +128,8 @@
<form id="form_with_multiple_select">
<input type="text" name="peewee" value="herman" />
- <select name="colors" multiple>
+ <input type="hidden" name="colors" value="pink" />
+ <select name="colors" multiple="multiple">
<option value="blue" selected>blue</option>
<option value="red">red</option>
<option value="green">green</option>
View
@@ -326,10 +326,16 @@ new Test.Unit.Runner({
this.assertEqual('select', select.aSelectMethod());
},
- testFormSerializeMultipleSelectToQueryString: function () {
+ testFormSerializeMultipleSelect: function () {
var form = $("form_with_multiple_select");
- this.assertEqual("peewee=herman&colors=blue&colors=yellow&colors=not+grey&number=2", form.serialize(false));
- },
+ this.assertEqual("peewee=herman&colors=pink&colors=blue&colors=yellow&colors=not+grey&number=2", form.serialize(false));
+ var hash = {
+ peewee: 'herman',
+ colors: ['pink', 'blue', 'yellow', 'not grey'],
+ number: '2'
+ };
+ this.assertHashEqual(hash, form.serialize(true));
+},
testFormRequest: function() {
var request = $("form").request();

0 comments on commit e6c89d2

Please sign in to comment.