Add type support to form-horizontal-control

Particularly to support checkboxes.
This commit is contained in:
Christopher Baines 2019-05-19 21:24:50 +01:00
parent d4b23f81c1
commit 78fb3fafc0

View file

@ -98,7 +98,8 @@
name name
help-text help-text
required? required?
options) options
(type "text"))
(define (value->text value) (define (value->text value)
(match value (match value
(#f "") (#f "")
@ -162,6 +163,7 @@
`(input (@ (class "form-control") `(input (@ (class "form-control")
(style "font-family: monospace;") (style "font-family: monospace;")
(id ,input-id) (id ,input-id)
(type ,type)
,@(if required? ,@(if required?
'((required #t)) '((required #t))
'()) '())
@ -173,9 +175,17 @@
query-parameters) query-parameters)
(#f '()) (#f '())
((_key . ($ <invalid-query-parameter> value)) ((_key . ($ <invalid-query-parameter> value))
`((value ,(value->text value)))) (if (string=? type "checkbox")
(if value
'((checked #t))
'())
`((value ,(value->text value)))))
((_key . 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? ,@(if show-help-span?
`((span (@ (id ,help-span-id) `((span (@ (id ,help-span-id)
(class "help-block")) (class "help-block"))