#440 bug
Shanrong Zhao

Form.Element.Serializers selectMany

Reported by Shanrong Zhao | November 11th, 2008 @ 11:35 PM | in 1.7

Actually, I don't think it's a bug, but feel it would work better (if minor changes).

selectMany: function(element) {

var values, length = element.length;
if (!length) return null;

for (var i = 0, values = []; i < length; i++) {
  var opt = element.options[i];
  if (opt.selected) values.push(this.optionValue(opt));
}
return values;

},

If none of options is seleted, empty array "[]" will be returned. As a result, when you serialize the form, an annoying/extra"&" will appear in the query string. Compare to "SelectOne" function, "null" will be returned.

Minor changes suggested:

return values; => return (values.length)? values: null;

Best regards,

Shanrong

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Prototype JavaScript library.

Shared Ticket Bins

Pages