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")
|
(make-request #"GET" (string->url "http://test.com")
|
||||||
empty
|
empty
|
||||||
(delay bs)
|
(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
|
(test-suite
|
||||||
"Input"
|
"Input"
|
||||||
|
|
||||||
|
@ -209,6 +211,18 @@
|
||||||
(test-equal? "textarea-input"
|
(test-equal? "textarea-input"
|
||||||
(test-process (textarea-input) (list (make-binding:form #"input_0" #"value")))
|
(test-process (textarea-input) (list (make-binding:form #"input_0" #"value")))
|
||||||
"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-equal? "to-string"
|
||||||
(test-process (to-string (required (text-input))) (list (make-binding:form #"input_0" #"value")))
|
(test-process (to-string (required (text-input))) (list (make-binding:form #"input_0" #"value")))
|
||||||
|
|
|
@ -122,9 +122,9 @@
|
||||||
; XXX button
|
; XXX button
|
||||||
|
|
||||||
(define (multiselect-input l
|
(define (multiselect-input l
|
||||||
#:multiple? [multiple? #t]
|
#:multiple? [multiple? #t]
|
||||||
#:selected? [selected? (λ (x) #f)]
|
#:selected? [selected? (λ (x) #f)]
|
||||||
#:display [display (λ (x) x)])
|
#:display [display (λ (x) x)])
|
||||||
(define value->element (make-hasheq))
|
(define value->element (make-hasheq))
|
||||||
(define i 0)
|
(define i 0)
|
||||||
(define (remember! e)
|
(define (remember! e)
|
||||||
|
@ -161,46 +161,56 @@
|
||||||
(cross
|
(cross
|
||||||
(pure first)
|
(pure first)
|
||||||
(multiselect-input l
|
(multiselect-input l
|
||||||
#:multiple? #f
|
#:multiple? #f
|
||||||
#:selected? selected?
|
#:selected? selected?
|
||||||
#:display display)))
|
#:display display)))
|
||||||
|
|
||||||
(define (textarea-input)
|
(define (textarea-input
|
||||||
(to-string
|
#:rows [rows #f]
|
||||||
(required
|
#:cols [cols #f])
|
||||||
|
(to-string
|
||||||
|
(required
|
||||||
(make-input
|
(make-input
|
||||||
(lambda (n)
|
(lambda (n)
|
||||||
(list 'textarea
|
(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
|
(provide/contract
|
||||||
[multiselect-input (->* (sequence?)
|
[multiselect-input (->* (sequence?)
|
||||||
(#:multiple? boolean?
|
(#:multiple? boolean?
|
||||||
#:selected? (any/c . -> . boolean?)
|
#:selected? (any/c . -> . boolean?)
|
||||||
#:display (any/c . -> . pretty-xexpr/c))
|
#:display (any/c . -> . pretty-xexpr/c))
|
||||||
(formlet/c (listof any/c)))]
|
(formlet/c (listof any/c)))]
|
||||||
[select-input (->* (sequence?)
|
[select-input (->* (sequence?)
|
||||||
(#:selected? (any/c . -> . boolean?)
|
(#:selected? (any/c . -> . boolean?)
|
||||||
#:display (any/c . -> . pretty-xexpr/c))
|
#:display (any/c . -> . pretty-xexpr/c))
|
||||||
(formlet/c any/c))]
|
(formlet/c any/c))]
|
||||||
[textarea-input (-> (formlet/c string?))]
|
[textarea-input (()
|
||||||
|
(#:rows number?
|
||||||
|
#:cols number?)
|
||||||
|
. ->* .
|
||||||
|
(formlet/c string?))]
|
||||||
[text-input (()
|
[text-input (()
|
||||||
(#:value (or/c false/c bytes?)
|
(#:value (or/c false/c bytes?)
|
||||||
#:size (or/c false/c exact-nonnegative-integer?)
|
#:size (or/c false/c exact-nonnegative-integer?)
|
||||||
#:max-length (or/c false/c exact-nonnegative-integer?)
|
#:max-length (or/c false/c exact-nonnegative-integer?)
|
||||||
#:read-only? boolean?
|
#:read-only? boolean?
|
||||||
#:attributes (listof (list/c symbol? string?)))
|
#:attributes (listof (list/c symbol? string?)))
|
||||||
. ->* .
|
. ->* .
|
||||||
(formlet/c (or/c false/c binding?)))]
|
(formlet/c (or/c false/c binding?)))]
|
||||||
[password-input (()
|
[password-input (()
|
||||||
(#:value (or/c false/c bytes?)
|
(#:value (or/c false/c bytes?)
|
||||||
#:size (or/c false/c exact-nonnegative-integer?)
|
#:size (or/c false/c exact-nonnegative-integer?)
|
||||||
#:max-length (or/c false/c exact-nonnegative-integer?)
|
#:max-length (or/c false/c exact-nonnegative-integer?)
|
||||||
#:read-only? boolean?
|
#:read-only? boolean?
|
||||||
#:attributes (listof (list/c symbol? string?)))
|
#:attributes (listof (list/c symbol? string?)))
|
||||||
. ->* .
|
. ->* .
|
||||||
(formlet/c (or/c false/c binding?)))]
|
(formlet/c (or/c false/c binding?)))]
|
||||||
[checkbox ((bytes? boolean?)
|
[checkbox ((bytes? boolean?)
|
||||||
(#:attributes (listof (list/c symbol? string?)))
|
(#: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.
|
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?)]{
|
(formlet/c string?)]{
|
||||||
This @tech{formlet} renders using an TEXTAREA element.
|
This @tech{formlet} renders using an TEXTAREA element.
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user