                              event-id)))
 
             create-activity
-            (fn [form]
+            (fn [e form]
               (when (empty? errors)
+                (.preventDefault e)
                 (activities-endpoint :create
                                      (let [start-time (:StartTime form)
                                            end-time   (:EndTime form)]

                (r/wrap Description swap! form assoc :Description)]]
              [:button.ui.primary.button {:class (when (seq errors) "disabled")
                                          :type :submit
                                          :on-click #(create-activity @form)}
               "Add"]]]
            [:div.ui.vertical.segment
             [:h2.ui.header


(defn event-activity-edit-page [event-id & [activity-id]]
  (let [form (atom {:EventId event-id})
        validator (validation-set (presence-of :Name)
                                  (presence-of :StartTime)
                                  (presence-of :EndTime)
                                  (format-of :EnrollmentCap :format #"^\d*$"
                                             :allow-blank true
                                             :allow-nil true))
        reset-form!
        (fn []
          (reset! form {:EventId event-id}))]
    (when activity-id
      (if-let [activity (seq (d/entity @activities-db activity-id))]
        (reset! form (into {} activity))
