forked from innoq/statuses
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove id attribute from hidden _method form field.
By default hiccup generates an id for every form field. In our case (more than one form with method DELETE on the same page) this leads to non unique ids which leads to w3c validation errors. Relates to innoq#130. Workaround for weavejester/hiccup#109.
- Loading branch information
Showing
2 changed files
with
21 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
(ns statuses.views.form | ||
(:require [hiccup.def :refer [defelem]] | ||
[hiccup.util :refer [to-uri]])) | ||
|
||
(defelem form-to | ||
"Create a form that points to a particular method and route. | ||
e.g. (form-to [:put \"/post\"] | ||
...)" | ||
[[method action] & body] | ||
(let [method-str (.toUpperCase (name method)) | ||
action-uri (to-uri action)] | ||
(-> (if (contains? #{:get :post} method) | ||
[:form {:method method-str, :action action-uri}] | ||
[:form {:method "POST", :action action-uri} | ||
[:input {:type "hidden" | ||
:name "_method" | ||
:value method-str}]]) | ||
(concat body) | ||
(vec)))) |
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