   (if (= :new id)
     :post
     :put))
+
+(defn save-election
+  [{:keys [db]} [_ id]]
+  (if-let [errors (form-errors db id)]
+    {:db (assoc-in db [:elections :errors id] errors)}
+    (let [data (election-params db id)]
+      {:db db
+       :http-xhrio {:method          (save-method id)
+                    :uri             (save-url db id)
+                    :params          data
+                    :timeout         8000
+                    :format          (ajax/json-request-format)
+                    :response-format (ajax/json-response-format)
+                    :on-success [:election-save/success id]
+                    :on-failure [:authorization/check [:election-save/failure]]}})))
+
+(defn save-election-success
+  [{:keys [db]} [_ id result]]
+  {:db (-> db
+           (assoc-in [:elections :forms id] db/fresh-election-form)
+           (update-in [:elections :errors] dissoc id))
+   :dispatch-n [[:flash/message "Election saved"]
+                [:elections-list/get]]})
+
+;; Delete Election
 
 (defn initiate-delete
   [db [_ election]]

  (assoc-in db [:elections :list]
            (map election-json->clj result)))

(defn election->form
  [election]
  {:id (:id election)

                :on-success [:election-delete/success]
                :on-failure [:election-delete/failure]}})

(defn election-delete-success
  [{:keys [db]} [_ id result]]
  {:db db
   :dispatch-n [[:flash/message "Election deleted"]
                [:close-modal]
                [:elections-list/get]]})

;; Elections List

(defn list-elections-params
  [db]
