|
|
|
@ -54,9 +54,7 @@
|
|
|
|
|
(defn drop-down
|
|
|
|
|
([form-def field req]
|
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
|
(drop-down form-def
|
|
|
|
|
field
|
|
|
|
|
req
|
|
|
|
|
(drop-down form-def field req
|
|
|
|
|
(get-in form-def [:fields field :options])))
|
|
|
|
|
([form-def field req options]
|
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
@ -71,6 +69,19 @@
|
|
|
|
|
options
|
|
|
|
|
field-value)))))
|
|
|
|
|
|
|
|
|
|
(defn check-box [form-def field req]
|
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
|
(let [field-value (get-in req [:params field])
|
|
|
|
|
field-def (get-in form-def [:fields field])
|
|
|
|
|
{:keys [label required] spec-key :spec} field-def]
|
|
|
|
|
(list
|
|
|
|
|
(when-not (field-valid? field-value spec-key req)
|
|
|
|
|
(spec-to-errmsg label spec-key field-value))
|
|
|
|
|
(hform/label field label)
|
|
|
|
|
(hform/check-box field
|
|
|
|
|
(some? field-value)
|
|
|
|
|
field-value))))
|
|
|
|
|
|
|
|
|
|
(defn valid? [form-def req]
|
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
|
(reduce-kv
|
|
|
|
|