|
|
@ -54,9 +54,7 @@
|
|
|
|
(defn drop-down
|
|
|
|
(defn drop-down
|
|
|
|
([form-def field req]
|
|
|
|
([form-def field req]
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
(drop-down form-def
|
|
|
|
(drop-down form-def field req
|
|
|
|
field
|
|
|
|
|
|
|
|
req
|
|
|
|
|
|
|
|
(get-in form-def [:fields field :options])))
|
|
|
|
(get-in form-def [:fields field :options])))
|
|
|
|
([form-def field req options]
|
|
|
|
([form-def field req options]
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
@ -71,6 +69,19 @@
|
|
|
|
options
|
|
|
|
options
|
|
|
|
field-value)))))
|
|
|
|
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]
|
|
|
|
(defn valid? [form-def req]
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
{:pre [(spec/valid? ::form form-def)]}
|
|
|
|
(reduce-kv
|
|
|
|
(reduce-kv
|
|
|
|