Skip to content

Commit e6c89d2

Browse files
author
Jorgen Rydenius
committed
Fixed bug #1384 for the hash accumulator + test case.
1 parent 24414bf commit e6c89d2

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/prototype/dom/form.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ var Form = {
113113
accumulator = function(result, key, value) {
114114
if (key in result) {
115115
if (!Object.isArray(result[key])) result[key] = [result[key]];
116-
result[key].push(value);
116+
result[key] = result[key].concat(value);
117117
} else result[key] = value;
118118
return result;
119119
};

test/unit/fixtures/form.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@
128128

129129
<form id="form_with_multiple_select">
130130
<input type="text" name="peewee" value="herman" />
131-
<select name="colors" multiple>
131+
<input type="hidden" name="colors" value="pink" />
132+
<select name="colors" multiple="multiple">
132133
<option value="blue" selected>blue</option>
133134
<option value="red">red</option>
134135
<option value="green">green</option>

test/unit/form_test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,16 @@ new Test.Unit.Runner({
326326
this.assertEqual('select', select.aSelectMethod());
327327
},
328328

329-
testFormSerializeMultipleSelectToQueryString: function () {
329+
testFormSerializeMultipleSelect: function () {
330330
var form = $("form_with_multiple_select");
331-
this.assertEqual("peewee=herman&colors=blue&colors=yellow&colors=not+grey&number=2", form.serialize(false));
332-
},
331+
this.assertEqual("peewee=herman&colors=pink&colors=blue&colors=yellow&colors=not+grey&number=2", form.serialize(false));
332+
var hash = {
333+
peewee: 'herman',
334+
colors: ['pink', 'blue', 'yellow', 'not grey'],
335+
number: '2'
336+
};
337+
this.assertHashEqual(hash, form.serialize(true));
338+
},
333339

334340
testFormRequest: function() {
335341
var request = $("form").request();

0 commit comments

Comments
 (0)