Fix submission forms for many2many fields with checkboxes
authorMagnus Hagander <magnus@hagander.net>
Mon, 11 Dec 2017 14:29:45 +0000 (15:29 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 11 Dec 2017 14:29:45 +0000 (15:29 +0100)
This includes proper styling (no more centering of the checkbox itself)
and actually saving the m2m fields on submit.

media/css/layout.css
pgweb/util/helpers.py

index 308ba5a3178b61838206234cb7bdd8f08265382d..7850f028e7b29647bb1ad06e13075795fb01116b 100644 (file)
@@ -640,7 +640,7 @@ TABLE.pgGenericFormTable TR {
    vertical-align: top;
 }
 
-TABLE.pgGenericFormTable TR TD INPUT,
+TABLE.pgGenericFormTable TR TD INPUT:not([type='checkbox']),
 TABLE.pgGenericFormTable TR TD SELECT,
 TABLE.pgGenericFormTable TR TD TEXTAREA,
 TABLE.pgGenericFormTable TR TD DIV.markdownpreview {
@@ -671,6 +671,10 @@ TABLE.pgGenericFormTable TR TH.formfieldnamecontainer {
   max-width: 300px;
 }
 
+TABLE.pgGenericFormTable TR TD UL {
+  list-style-type: none;
+}
+
 /* Misc Classes */
 
 .pgClearBoth {
index 87e586ce099cdc63aff156da718ace7741d695c7..b24885bfba6590cfb2ff0c10496eab9f4ec0e54f 100644 (file)
@@ -43,6 +43,8 @@ def simple_form(instancetype, itemid, request, formclass, formtemplate='base/for
                                form.apply_submitter(r, request.user)
                                r.save()
 
+                       form.save_m2m()
+
                        return HttpResponseRedirect(redirect)
        else:
                # Generate form