public
Fork of sstephenson/prototype
Description: Prototype JavaScript framework
Homepage: http://prototypejs.org/
Clone URL: git://github.com/jdalton/prototype.git
Search Repo:
Form#serializeElements should not serialize file inputs.

(cherry picked from commit 49f2f08b31c853d1639a56d0d78cf8a14bb8d848)
Tue May 06 13:12:18 -0700 2008
commit  bc60b6d207ef30201f34ae2716386602db4cc70a
tree    cd70cbb8594d525cdff74e51652853421b1965c2
parent  34fa0557d93cddeb4462d307204a320b38f6ca5e
...
12
13
14
15
 
16
17
18
...
12
13
14
 
15
16
17
18
0
@@ -12,7 +12,7 @@
0
     var data = elements.inject({ }, function(result, element) {
0
       if (!element.disabled && element.name) {
0
         key = element.name; value = $(element).getValue();
0
- if (value != null && && (element.type != 'submit' || (!submitted &&
0
+ if (value != null && element.type != 'file' && (element.type != 'submit' || (!submitted &&
0
             submit !== false && (!submit || key == submit) && (submitted = true)))) {
0
           if (key in result) {
0
             // a key is already present; construct an array of values
...
79
80
81
 
 
 
 
82
83
84
...
79
80
81
82
83
84
85
86
87
88
0
@@ -79,6 +79,10 @@
0
   <input type="text" />
0
 </form>
0
 
0
+<form id="form_with_file_input">
0
+ <input type="file" name="file_name" value="foo" />
0
+</form>
0
+
0
 <!-- tabindexed forms -->
0
 <div id="tabindex">
0
   <form id="ffe">
...
271
272
273
274
 
 
 
275
276
277
...
271
272
273
 
274
275
276
277
278
279
0
@@ -271,7 +271,9 @@
0
                     $('form').serialize({ submit: false }));
0
     this.assertHashEqual({ val1:4, action:'blah' },
0
                     $('form').serialize({ submit: 'inexistent' }));
0
-
0
+
0
+ // file input should not be serialized
0
+ this.assertEqual('', $('form_with_file_input').serialize());
0
   },
0
   
0
   testFormMethodsOnExtendedElements: function() {

Comments

    No one has commented yet.