aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2019-05-19 21:24:50 +0100
committerChristopher Baines <mail@cbaines.net>2019-05-19 21:24:50 +0100
commit78fb3fafc03617ff8a1427b8928e603d5a6307a6 (patch)
treee1e9a8456ed6481e279fa41dfa2b6a31d1763d00
parentd4b23f81c17c37827b84dd98e0bae05c9bf8bc1d (diff)
downloaddata-service-78fb3fafc03617ff8a1427b8928e603d5a6307a6.tar
data-service-78fb3fafc03617ff8a1427b8928e603d5a6307a6.tar.gz
Add type support to form-horizontal-control
Particularly to support checkboxes.
-rw-r--r--guix-data-service/web/view/html.scm16
1 files changed, 13 insertions, 3 deletions
diff --git a/guix-data-service/web/view/html.scm b/guix-data-service/web/view/html.scm
index 1d7a7d0..2e3991c 100644
--- a/guix-data-service/web/view/html.scm
+++ b/guix-data-service/web/view/html.scm
@@ -98,7 +98,8 @@
name
help-text
required?
- options)
+ options
+ (type "text"))
(define (value->text value)
(match value
(#f "")
@@ -162,6 +163,7 @@
`(input (@ (class "form-control")
(style "font-family: monospace;")
(id ,input-id)
+ (type ,type)
,@(if required?
'((required #t))
'())
@@ -173,9 +175,17 @@
query-parameters)
(#f '())
((_key . ($ <invalid-query-parameter> value))
- `((value ,(value->text value))))
+ (if (string=? type "checkbox")
+ (if value
+ '((checked #t))
+ '())
+ `((value ,(value->text value)))))
((_key . value)
- `((value ,(value->text value))))))))
+ (if (string=? type "checkbox")
+ (if (peek "VALUE" value)
+ '((checked #t))
+ '())
+ `((value ,(value->text value)))))))))
,@(if show-help-span?
`((span (@ (id ,help-span-id)
(class "help-block"))