[forms] fix form enctype handling with inlined forms stable
authorAdrien Di Mascio <Adrien.DiMascio@logilab.fr>
Tue, 08 Sep 2009 21:57:45 +0200
branchstable
changeset 3124 c929360212ca
parent 3114 f87fd632e3f6
child 3127 920079cb4e5b
[forms] fix form enctype handling with inlined forms If an inlined form is added dynamically and contains a file input, the parent form enctype must be set to multiplart/form-data otherwise files won't be uploaded correctly.
web/data/cubicweb.edition.js
--- a/web/data/cubicweb.edition.js	Tue Sep 08 15:58:47 2009 +0200
+++ b/web/data/cubicweb.edition.js	Tue Sep 08 21:57:45 2009 +0200
@@ -255,6 +255,11 @@
         updateInlinedEntitiesCounters(rtype);
         reorderTabindex();
         form.trigger('inlinedform-added');
+        // if the inlined form contains a file input, we must force
+        // the form enctype to multipart/form-data
+        if (form.find('input:file').length) {
+            form.closest('form').attr('enctype', 'multipart/form-data');
+        }
         postAjaxLoad(dom);
     });
     d.addErrback(function (xxx) {