From 359ac41a45579c997c6a77f245d20c283dde8b6d Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Mon, 27 Jun 2011 12:08:10 -0600 Subject: [PATCH] Updating textarea-input re Shogo --- collects/tests/web-server/formlets-test.rkt | 9 +++++++++ collects/web-server/formlets/input.rkt | 10 +++++++--- collects/web-server/scribblings/formlets.scrbl | 3 ++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/collects/tests/web-server/formlets-test.rkt b/collects/tests/web-server/formlets-test.rkt index 3b4861b76f..5dfff56f9f 100644 --- a/collects/tests/web-server/formlets-test.rkt +++ b/collects/tests/web-server/formlets-test.rkt @@ -220,6 +220,15 @@ (test-equal? "textarea-input" (test-display (textarea-input #:cols 80 #:rows 70)) '((textarea ([name "input_0"] [rows "70"] [cols "80"]) ""))) + (test-equal? "textarea-input" + (test-display (textarea-input #:rows 80 #:attributes '([class "awesome"]))) + '((textarea ([name "input_0"] [rows "80"] [class "awesome"]) ""))) + (test-equal? "textarea-input" + (test-display (textarea-input #:cols 80 #:attributes '([class "awesome"]))) + '((textarea ([name "input_0"] [cols "80"] [class "awesome"]) ""))) + (test-equal? "textarea-input" + (test-display (textarea-input #:cols 80 #:rows 70 #:attributes '([class "awesome"]))) + '((textarea ([name "input_0"] [rows "70"] [cols "80"] [class "awesome"]) ""))) ; checkbox (test-equal? "checkbox" diff --git a/collects/web-server/formlets/input.rkt b/collects/web-server/formlets/input.rkt index fe1acf47b6..34f9bebab5 100644 --- a/collects/web-server/formlets/input.rkt +++ b/collects/web-server/formlets/input.rkt @@ -223,6 +223,7 @@ #:display display))) (define (textarea-input + #:attributes [attrs empty] #:rows [rows #f] #:cols [cols #f]) (make-input @@ -232,7 +233,8 @@ (append (filter list? (list (and rows (list 'rows (number->string rows))) - (and cols (list 'cols (number->string cols))))))) + (and cols (list 'cols (number->string cols))))) + attrs)) "")))) (provide/contract @@ -307,8 +309,10 @@ . ->* . (formlet/c any/c))] [textarea-input (() - (#:rows number? - #:cols number?) + (#:attributes + (listof (list/c symbol? string?)) + #:rows number? + #:cols number?) . ->* . (formlet/c (or/c false/c binding?)))]) diff --git a/collects/web-server/scribblings/formlets.scrbl b/collects/web-server/scribblings/formlets.scrbl index a49845a716..7b5d57483f 100644 --- a/collects/web-server/scribblings/formlets.scrbl +++ b/collects/web-server/scribblings/formlets.scrbl @@ -305,7 +305,8 @@ These @tech{formlet}s are the main combinators for form input. } @defproc[(textarea-input [#:rows rows (or/c false/c number?) #f] - [#:cols cols (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?))]{ This @tech{formlet} renders using an TEXTAREA element with attributes given in the arguments. }