Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
documents and provides example for forms
- Loading branch information
Showing
7 changed files
with
98 additions
and
6 deletions.
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
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
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
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,44 @@ | ||
(ns example.forms-demo | ||
(:require-macros [hiccup.core :as h]) | ||
(:require [clojure.string :as string] | ||
[com.eighthlight.filament.forms :as forms] | ||
[com.eighthlight.filament.util :as util] | ||
[domina :as dom] | ||
[hiccup.core])) | ||
|
||
(def dom [:div.example | ||
[:h2 "com.eighthlight.filament.forms"] | ||
[:p "Click on the buttons below to see how their corresponding functions behave on the following form."] | ||
[:button#form-data "Demonstrate form-date"] | ||
[:button#show-errors "Demonstrate display-errors"] | ||
[:button#clear-errors "Demonstrate teardown-errors"] | ||
[:form#forms-demo-form {:action "/fooey" :autocomplete "off"} | ||
[:div | ||
[:label {:for "field1"} "Field 1:"] | ||
[:input#field1 {:name "field1" :type "text" :value "1"}]] | ||
[:div | ||
[:label {:for "field2"} "Field 2:"] | ||
[:select#field2 {:name "field2"} | ||
[:option "Yes"] | ||
[:option "No"] | ||
[:option "Maybe"]]] | ||
[:div | ||
[:label {:for "field3"} "Field 3:"] | ||
[:textarea#field3 {:name "field3"} "Some content"]]]]) | ||
|
||
(defn show-form-data [] | ||
(js/alert (pr-str (forms/form-data (dom/by-id "forms-demo-form"))))) | ||
|
||
(def model-with-errors {:errors {:field1 ["has one error"] | ||
:field2 ["first error" "second error"] | ||
:field3 ["last error"]}}) | ||
(defn display-errors [] | ||
(forms/display-errors model-with-errors)) | ||
|
||
(defn demo-forms [] | ||
(dom/append! (.-body js/document) (h/html dom)) | ||
(util/override-click! (dom/by-id "form-data") show-form-data) | ||
(util/override-click! (dom/by-id "show-errors") display-errors) | ||
(util/override-click! (dom/by-id "clear-errors") forms/teardown-errors) | ||
) | ||
|
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
(ns example.main | ||
(:require [example.autocomplete-demo :refer [demo-autocomplete]] | ||
[example.forms-demo :refer [demo-forms]] | ||
[example.modal-demo :refer [demo-modal]])) | ||
|
||
(defn ^:export init [] | ||
(demo-autocomplete) | ||
(demo-forms) | ||
(demo-modal)) |
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
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