             (om/build item-view entry)))
         (dom/div nil
           (dom/h3 nil "New entry")
-          (dom/form #js {:className "form-horizontal"}
-            (dom/input #js {:type "text"
-                            :className "form-control"
-                            :value (:summary state)
-                            :onChange (fn [e]
-                                        (om/set-state! component :summary
-                                          (-> e .-target .-value)))
-                            :placeholder "Summary"})
-            (dom/input #js {:type "text"
-                            :className "form-control"
-                            :value (:date-time state)
-                            :onChange (fn [e]
-                                        (om/set-state! component :date-time
-                                          (-> e .-target .-value)))
-                            :placeholder "Time"})
-            (dom/textarea #js {:className "form-control":placeholder "Notes"
-                               :value (:notes state)
-                               :onChange (fn [e]
-                                           (om/set-state! component :notes
-                                             (-> e .-target .-value)))
-                               :rows "5"})
-            (dom/button #js {:className "btn btn-primary"
-                             :onClick (fn [e]
-                                        (.preventDefault e)
-                                        (om/transact! cursor :entries
-                                          (fn [entries]
-                                            ((fnil conj []) entries
-                                             {:summary (:summary state)
-                                              :date-time (:date-time state)
-                                              :notes (:notes state)}))))}
-              "Save")))))))
+          (om/build item-form {}
+            {:opts {:on-save (fn [summary date-time notes]
+                               (om/transact! cursor :entries
+                                 (fn [entries]
+                                   ((fnil conj []) entries
+                                    {:summary summary
+                                     :date-time date-time
+                                     :notes notes}))))}}))))))
 
 (defn app-container [cursor component]
   (reify

  (reify
    om/IInitState
    (init-state [this]
      {:summary ""
       :date-time ""
       :notes ""})
    om/IRenderState
    (render-state [this state]
      (dom/div nil

            [om.dom :as dom]))

(defonce appstate (atom {}))

(defn item-form [cursor component options]
  (reify
    om/IInitState
    (init-state [this]
      {:summary (get cursor :summary "")
       :date-time (get cursor :date-time "")
       :notes (get cursor :notes "")})
    om/IRenderState
    (render-state [this state]
      (dom/form #js {:className "form-horizontal"}
        (dom/input #js {:type "text"
                        :className "form-control"
                        :value (:summary state)
                        :onChange (fn [e]
                                    (om/set-state! component :summary
                                      (-> e .-target .-value)))
                        :placeholder "Summary"})
        (dom/input #js {:type "text"
                        :className "form-control"
                        :value (:date-time state)
                        :onChange (fn [e]
                                    (om/set-state! component :date-time
                                      (-> e .-target .-value)))
                        :placeholder "Time"})
        (dom/textarea #js {:className "form-control":placeholder "Notes"
                           :value (:notes state)
                           :onChange (fn [e]
                                       (om/set-state! component :notes
                                         (-> e .-target .-value)))
                           :rows "5"})
        (dom/button #js {:className "btn btn-primary"
                         :onClick (fn [e]
                                    (.preventDefault e)
                                    (when-let [on-save (:on-save options)]
                                      (on-save (:summary state) (:date-time state) (:notes state))))}
          "Save")))))

(defn item-view [cursor component]
  (reify
