Skip to content

Instantly share code, notes, and snippets.

@mrowe
Created January 8, 2013 05:54
Show Gist options
  • Save mrowe/4481577 to your computer and use it in GitHub Desktop.
Save mrowe/4481577 to your computer and use it in GitHub Desktop.
Rerender GET on POST on validation error
(defn create-form [{:keys [env name type]}]
(common/layout
[:h2 (str "Create instance in " env)]
(form-to [:post (str "/environments/" env "/create")]
(hidden-field "env" env) (hidden-field "principal" "web-ui")
(instance-fields name type)
(submit-button "Create"))))
(defroutes node-routes
;; [...]
(GET "/environments/:env/create" {params :params}
(create-form params))
(POST "/environments/:env/create" [env :as {instance :params}]
(if (valid? instance)
(do
(fakeec2/create-instance instance)
(redirect (str "/environments/" env)))
(create-form instance))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment