|
|
@ -1,6 +1,8 @@
|
|
|
|
(ns formulare.theme
|
|
|
|
(ns formulare.theme
|
|
|
|
(:require [clojure.spec.alpha :as spec]
|
|
|
|
(:require [clojure.spec.alpha :as spec]
|
|
|
|
[hiccup.form :as hform]))
|
|
|
|
[hiccup
|
|
|
|
|
|
|
|
[form :as hform]
|
|
|
|
|
|
|
|
[core :as hcore]]))
|
|
|
|
|
|
|
|
|
|
|
|
(defn row [& content] content)
|
|
|
|
(defn row [& content] content)
|
|
|
|
|
|
|
|
|
|
|
@ -15,9 +17,11 @@
|
|
|
|
(fn [prob]
|
|
|
|
(fn [prob]
|
|
|
|
[:p
|
|
|
|
[:p
|
|
|
|
"Field "
|
|
|
|
"Field "
|
|
|
|
[:span.flash__field (:label field-def)]
|
|
|
|
[:span.flash__field
|
|
|
|
|
|
|
|
(hcore/h (:label field-def))]
|
|
|
|
" must comply to "
|
|
|
|
" must comply to "
|
|
|
|
[:span.flash__pred (:pred prob)]])
|
|
|
|
[:span.flash__pred
|
|
|
|
|
|
|
|
(hcore/h (:pred prob))]])
|
|
|
|
(:clojure.spec.alpha/problems
|
|
|
|
(:clojure.spec.alpha/problems
|
|
|
|
(spec/explain-data (:spec field-def)
|
|
|
|
(spec/explain-data (:spec field-def)
|
|
|
|
field-value)))))
|
|
|
|
field-value)))))
|
|
|
@ -27,7 +31,7 @@
|
|
|
|
(spec/explain-data % req))
|
|
|
|
(spec/explain-data % req))
|
|
|
|
(:form-specs form-def))]
|
|
|
|
(:form-specs form-def))]
|
|
|
|
(err-msg [:p "The form must comply to "
|
|
|
|
(err-msg [:p "The form must comply to "
|
|
|
|
(:pred prob)])))
|
|
|
|
(hcore/h (:pred prob))])))
|
|
|
|
|
|
|
|
|
|
|
|
(defn label [field-id field-def]
|
|
|
|
(defn label [field-id field-def]
|
|
|
|
(when-not (= :hidden (:widget field-def))
|
|
|
|
(when-not (= :hidden (:widget field-def))
|
|
|
@ -57,14 +61,17 @@
|
|
|
|
(defn multiselect-widget [id def value]
|
|
|
|
(defn multiselect-widget [id def value]
|
|
|
|
(let [options (:options def)]
|
|
|
|
(let [options (:options def)]
|
|
|
|
[:select {:multiple "multiple"
|
|
|
|
[:select {:multiple "multiple"
|
|
|
|
:size 5
|
|
|
|
:size (:size def 5)
|
|
|
|
:name (name id)
|
|
|
|
:name (name id)
|
|
|
|
:id (name id)}
|
|
|
|
:id (name id)}
|
|
|
|
(for [option options]
|
|
|
|
(for [option options]
|
|
|
|
[:option {:value (second option)
|
|
|
|
[:option {:value (second option)
|
|
|
|
:selected (some? (some (partial = (second option))
|
|
|
|
:selected (some? (some (partial = (second option))
|
|
|
|
value))}
|
|
|
|
value))}
|
|
|
|
(first option)])]))
|
|
|
|
(hcore/h (first option))])]))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(comment
|
|
|
|
|
|
|
|
(multiselect-widget :id {:options [["<>" "key"]]} {}))
|
|
|
|
|
|
|
|
|
|
|
|
(defn hidden-widget [id def value]
|
|
|
|
(defn hidden-widget [id def value]
|
|
|
|
(hform/hidden-field id value))
|
|
|
|
(hform/hidden-field id value))
|
|
|
|