Adding attributes to select-input
This commit is contained in:
parent
8fb23b0825
commit
c2f8e4c0fe
|
@ -383,6 +383,13 @@
|
|||
(option ((value "0")) 1)
|
||||
(option ((value "1")) 2)
|
||||
(option ((value "2")) 3))))
|
||||
(test-equal? "multiselect-input"
|
||||
(test-display (multiselect-input (list 1 2 3) #:attributes '([test "val"])))
|
||||
'((select
|
||||
((multiple "true") (name "input_0") (test "val"))
|
||||
(option ((value "0")) 1)
|
||||
(option ((value "1")) 2)
|
||||
(option ((value "2")) 3))))
|
||||
(test-equal? "multiselect-input"
|
||||
(test-display (multiselect-input (list 1 2 3) #:multiple? #t))
|
||||
'((select
|
||||
|
@ -434,6 +441,13 @@
|
|||
(option ((value "0")) 1)
|
||||
(option ((value "1")) 2)
|
||||
(option ((value "2")) 3))))
|
||||
(test-equal? "select-input"
|
||||
(test-display (select-input (list 1 2 3) #:attributes '([test "val"])))
|
||||
'((select
|
||||
((name "input_0") [test "val"])
|
||||
(option ((value "0")) 1)
|
||||
(option ((value "1")) 2)
|
||||
(option ((value "2")) 3))))
|
||||
(test-equal? "select-input"
|
||||
(test-display (select-input (list 1 2 3) #:selected? even?))
|
||||
'((select
|
||||
|
|
|
@ -174,6 +174,7 @@
|
|||
attrs))))))
|
||||
|
||||
(define (multiselect-input l
|
||||
#:attributes [attrs empty]
|
||||
#:multiple? [multiple? #t]
|
||||
#:selected? [selected? (λ (x) #f)]
|
||||
#:display [display (λ (x) x)])
|
||||
|
@ -198,7 +199,8 @@
|
|||
(make-input*
|
||||
(lambda (name)
|
||||
`(select (,@(if multiple? '([multiple "true"]) empty)
|
||||
[name ,name])
|
||||
[name ,name]
|
||||
,@attrs)
|
||||
,@(for/list ([(vn e) (in-hash value->element)])
|
||||
(define v (number->string vn))
|
||||
`(option ([value ,v]
|
||||
|
@ -208,11 +210,13 @@
|
|||
,(display e))))))))
|
||||
|
||||
(define (select-input l
|
||||
#:attributes [attrs empty]
|
||||
#:selected? [selected? (λ (x) #f)]
|
||||
#:display [display (λ (x) x)])
|
||||
(cross
|
||||
(pure first)
|
||||
(multiselect-input l
|
||||
#:attributes attrs
|
||||
#:multiple? #f
|
||||
#:selected? selected?
|
||||
#:display display)))
|
||||
|
@ -280,20 +284,25 @@
|
|||
. ->* .
|
||||
(formlet/c (or/c false/c binding?)))]
|
||||
[button ((bytes? bytes?)
|
||||
(#:disabled boolean?
|
||||
#:value (or/c false/c bytes?)
|
||||
#:attributes (listof (list/c symbol? string?)))
|
||||
(#:disabled
|
||||
boolean?
|
||||
#:value (or/c false/c bytes?)
|
||||
#:attributes (listof (list/c symbol? string?)))
|
||||
. ->* .
|
||||
(formlet/c (or/c false/c binding?)))]
|
||||
[multiselect-input ((sequence?)
|
||||
(#:multiple? boolean?
|
||||
#:selected? (any/c . -> . boolean?)
|
||||
#:display (any/c . -> . pretty-xexpr/c))
|
||||
(#:attributes
|
||||
(listof (list/c symbol? string?))
|
||||
#:multiple? boolean?
|
||||
#:selected? (any/c . -> . boolean?)
|
||||
#:display (any/c . -> . pretty-xexpr/c))
|
||||
. ->* .
|
||||
(formlet/c (listof any/c)))]
|
||||
[select-input ((sequence?)
|
||||
(#:selected? (any/c . -> . boolean?)
|
||||
#:display (any/c . -> . pretty-xexpr/c))
|
||||
(#:attributes
|
||||
(listof (list/c symbol? string?))
|
||||
#:selected? (any/c . -> . boolean?)
|
||||
#:display (any/c . -> . pretty-xexpr/c))
|
||||
. ->* .
|
||||
(formlet/c any/c))]
|
||||
[textarea-input (()
|
||||
|
|
|
@ -367,18 +367,20 @@ These @tech{formlet}s are the main combinators for form input.
|
|||
}
|
||||
|
||||
@defproc[(multiselect-input [l sequence?]
|
||||
[#:attributes attrs (listof (list/c symbol? string?)) empty]
|
||||
[#:multiple? multiple? boolean? #t]
|
||||
[#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)]
|
||||
[#:display display (any/c . -> . xexpr/c) (λ (x) x)])
|
||||
(formlet/c list?)]{
|
||||
This @tech{formlet} renders using an SELECT element with an OPTION for each element of the sequence. If @racket[multiple?] is @racket[#t], then multiple options may be selected. An element is selected if @racket[selected?] returns @racket[#t]. Elements are displayed with @racket[display].
|
||||
This @tech{formlet} renders using an SELECT element with the attributes given with an OPTION for each element of the sequence. If @racket[multiple?] is @racket[#t], then multiple options may be selected. An element is selected if @racket[selected?] returns @racket[#t]. Elements are displayed with @racket[display].
|
||||
}
|
||||
|
||||
@defproc[(select-input [l sequence?]
|
||||
[#:attributes attrs (listof (list/c symbol? string?)) empty]
|
||||
[#:selected? selected? (any/c . -> . boolean?) (λ (x) #f)]
|
||||
[#:display display (any/c . -> . xexpr/c) (λ (x) x)])
|
||||
(formlet/c any/c)]{
|
||||
This @tech{formlet} renders using an SELECT element with an OPTION for each element of the sequence. An element is selected if @racket[selected?] returns @racket[#t]. Elements are displayed with @racket[display].
|
||||
This @tech{formlet} renders using an SELECT element with the attributes given with an OPTION for each element of the sequence. An element is selected if @racket[selected?] returns @racket[#t]. Elements are displayed with @racket[display].
|
||||
}
|
||||
|
||||
@defproc[(required [f (formlet/c (or/c false/c binding?))])
|
||||
|
|
Loading…
Reference in New Issue
Block a user