Created
January 8, 2013 05:54
-
-
Save mrowe/4481577 to your computer and use it in GitHub Desktop.
Rerender GET on POST on validation error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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