Added attributes to textarea-input based on patch from Horace Dynamite

This commit is contained in:
Jay McCarthy 2010-08-06 20:08:03 -06:00
parent f86edf3c8e
commit 8a67fceb4a
3 changed files with 55 additions and 30 deletions

View File

@ -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")))

View File

@ -165,13 +165,19 @@
#:selected? selected? #:selected? selected?
#:display display))) #:display display)))
(define (textarea-input) (define (textarea-input
#:rows [rows #f]
#:cols [cols #f])
(to-string (to-string
(required (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
@ -184,7 +190,11 @@
(#: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?)

View File

@ -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.
} }