diff --git a/collects/tests/web-server/formlets-test.rkt b/collects/tests/web-server/formlets-test.rkt index a25d33e6f9..34b9703af0 100644 --- a/collects/tests/web-server/formlets-test.rkt +++ b/collects/tests/web-server/formlets-test.rkt @@ -217,6 +217,9 @@ (test-equal? "textarea-input" (test-display (textarea-input #:cols 80)) '((textarea ([name "input_0"] [cols "80"]) ""))) + (test-equal? "textarea-input" + (test-display (textarea-input #:value #"starting text" #:cols 80)) + '((textarea ([name "input_0"] [cols "80"]) "starting text"))) (test-equal? "textarea-input" (test-display (textarea-input #:cols 80 #:rows 70)) '((textarea ([name "input_0"] [rows "70"] [cols "80"]) ""))) diff --git a/collects/web-server/formlets/input.rkt b/collects/web-server/formlets/input.rkt index 34f9bebab5..6504fc635f 100644 --- a/collects/web-server/formlets/input.rkt +++ b/collects/web-server/formlets/input.rkt @@ -223,6 +223,7 @@ #:display display))) (define (textarea-input + #:value [value #f] #:attributes [attrs empty] #:rows [rows #f] #:cols [cols #f]) @@ -234,8 +235,10 @@ (filter list? (list (and rows (list 'rows (number->string rows))) (and cols (list 'cols (number->string cols))))) - attrs)) - "")))) + attrs)) + (if value + (bytes->string/utf-8 value) + ""))))) (provide/contract [text-input (() @@ -311,6 +314,7 @@ [textarea-input (() (#:attributes (listof (list/c symbol? string?)) + #:value (or/c false/c bytes?) #:rows number? #:cols number?) . ->* . diff --git a/collects/web-server/scribblings/formlets.scrbl b/collects/web-server/scribblings/formlets.scrbl index 7b5d57483f..6b24216daa 100644 --- a/collects/web-server/scribblings/formlets.scrbl +++ b/collects/web-server/scribblings/formlets.scrbl @@ -304,7 +304,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 [#:rows rows (or/c false/c number?) #f] +@defproc[(textarea-input [#:value value (or/c false/c bytes?) #f] + [#:rows rows (or/c false/c number?) #f] [#:cols cols (or/c false/c number?) #f] [#:attributes attrs (listof (list/c symbol? string?)) empty]) (formlet/c (or/c false/c binding?))]{