Added attributes to textarea-input based on patch from Horace Dynamite
This commit is contained in:
parent
f86edf3c8e
commit
8a67fceb4a
|
@ -127,7 +127,9 @@
|
|||
(make-request #"GET" (string->url "http://test.com")
|
||||
empty
|
||||
(delay bs)
|
||||
#f "127.0.0.1" 80 "127.0.0.1")))]
|
||||
#f "127.0.0.1" 80 "127.0.0.1")))
|
||||
(define (test-display f)
|
||||
(formlet-display f))]
|
||||
(test-suite
|
||||
"Input"
|
||||
|
||||
|
@ -209,6 +211,18 @@
|
|||
(test-equal? "textarea-input"
|
||||
(test-process (textarea-input) (list (make-binding:form #"input_0" #"value")))
|
||||
"value")
|
||||
(test-equal? "textarea-input"
|
||||
(test-display (textarea-input))
|
||||
'((textarea ([name "input_0"]) "")))
|
||||
(test-equal? "textarea-input"
|
||||
(test-display (textarea-input #:rows 80))
|
||||
'((textarea ([name "input_0"] [rows "80"]) "")))
|
||||
(test-equal? "textarea-input"
|
||||
(test-display (textarea-input #:cols 80))
|
||||
'((textarea ([name "input_0"] [cols "80"]) "")))
|
||||
(test-equal? "textarea-input"
|
||||
(test-display (textarea-input #:cols 80 #:rows 70))
|
||||
'((textarea ([name "input_0"] [rows "70"] [cols "80"]) "")))
|
||||
|
||||
(test-equal? "to-string"
|
||||
(test-process (to-string (required (text-input))) (list (make-binding:form #"input_0" #"value")))
|
||||
|
|
|
@ -122,9 +122,9 @@
|
|||
; XXX button
|
||||
|
||||
(define (multiselect-input l
|
||||
#:multiple? [multiple? #t]
|
||||
#:selected? [selected? (λ (x) #f)]
|
||||
#:display [display (λ (x) x)])
|
||||
#:multiple? [multiple? #t]
|
||||
#:selected? [selected? (λ (x) #f)]
|
||||
#:display [display (λ (x) x)])
|
||||
(define value->element (make-hasheq))
|
||||
(define i 0)
|
||||
(define (remember! e)
|
||||
|
@ -161,46 +161,56 @@
|
|||
(cross
|
||||
(pure first)
|
||||
(multiselect-input l
|
||||
#:multiple? #f
|
||||
#:selected? selected?
|
||||
#:display display)))
|
||||
#:multiple? #f
|
||||
#:selected? selected?
|
||||
#:display display)))
|
||||
|
||||
(define (textarea-input)
|
||||
(define (textarea-input
|
||||
#:rows [rows #f]
|
||||
#:cols [cols #f])
|
||||
(to-string
|
||||
(required
|
||||
(make-input
|
||||
(lambda (n)
|
||||
(list 'textarea
|
||||
(list (list 'name n))
|
||||
(list* (list 'name n)
|
||||
(append
|
||||
(filter list?
|
||||
(list (and rows (list 'rows (number->string rows)))
|
||||
(and cols (list 'cols (number->string cols)))))))
|
||||
""))))))
|
||||
|
||||
(provide/contract
|
||||
[multiselect-input (->* (sequence?)
|
||||
(#:multiple? boolean?
|
||||
#:selected? (any/c . -> . boolean?)
|
||||
#:display (any/c . -> . pretty-xexpr/c))
|
||||
#: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))
|
||||
#:display (any/c . -> . pretty-xexpr/c))
|
||||
(formlet/c any/c))]
|
||||
[textarea-input (-> (formlet/c string?))]
|
||||
[textarea-input (()
|
||||
(#:rows number?
|
||||
#:cols number?)
|
||||
. ->* .
|
||||
(formlet/c string?))]
|
||||
[text-input (()
|
||||
(#:value (or/c false/c bytes?)
|
||||
#:size (or/c false/c exact-nonnegative-integer?)
|
||||
#:max-length (or/c false/c exact-nonnegative-integer?)
|
||||
#:read-only? boolean?
|
||||
#:attributes (listof (list/c symbol? string?)))
|
||||
. ->* .
|
||||
(formlet/c (or/c false/c binding?)))]
|
||||
(#:value (or/c false/c bytes?)
|
||||
#:size (or/c false/c exact-nonnegative-integer?)
|
||||
#:max-length (or/c false/c exact-nonnegative-integer?)
|
||||
#:read-only? boolean?
|
||||
#:attributes (listof (list/c symbol? string?)))
|
||||
. ->* .
|
||||
(formlet/c (or/c false/c binding?)))]
|
||||
[password-input (()
|
||||
(#:value (or/c false/c bytes?)
|
||||
#:size (or/c false/c exact-nonnegative-integer?)
|
||||
#:max-length (or/c false/c exact-nonnegative-integer?)
|
||||
#:read-only? boolean?
|
||||
#:attributes (listof (list/c symbol? string?)))
|
||||
. ->* .
|
||||
(formlet/c (or/c false/c binding?)))]
|
||||
(#:value (or/c false/c bytes?)
|
||||
#:size (or/c false/c exact-nonnegative-integer?)
|
||||
#:max-length (or/c false/c exact-nonnegative-integer?)
|
||||
#:read-only? boolean?
|
||||
#:attributes (listof (list/c symbol? string?)))
|
||||
. ->* .
|
||||
(formlet/c (or/c false/c binding?)))]
|
||||
[checkbox ((bytes? boolean?)
|
||||
(#:attributes (listof (list/c symbol? string?)))
|
||||
. ->* .
|
||||
|
|
|
@ -303,7 +303,8 @@ These @tech{formlet}s are the main combinators for form input.
|
|||
This @tech{formlet} renders using an INPUT element with the PASSWORD type and the attributes given in the arguments.
|
||||
}
|
||||
|
||||
@defproc[(textarea-input)
|
||||
@defproc[(textarea-input [#:rows rows (or/c false/c number?) #f]
|
||||
[#:cols cols (or/c false/c number?) #f])
|
||||
(formlet/c string?)]{
|
||||
This @tech{formlet} renders using an TEXTAREA element.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user