factor out transformers

This commit is contained in:
interp 2002-10-02 12:02:56 +00:00
parent c85bcfc502
commit 03eeb86a5f
1 changed files with 16 additions and 11 deletions

View File

@ -313,15 +313,19 @@
,(and attributes (cdr attributes))
))))))
(define (make-number-input-field . maybe-further-attributes)
(define make-number-input-field
(let ((number-input-field-transformer
(lambda (string)
(or (string->number string)
(error "wrong type")))
))
(lambda maybe-further-attributes)
(let ((name (generate-input-field-name "number")))
(optionals maybe-further-attributes
((attributes XML-attribute?))
(make-input-field
name
(lambda (string)
(or (string->number string)
(error "wrong type")))
number-input-field-transformer
`(input (@ (type "text")
(name ,name)
,(and attributes (cdr attributes))))))))
@ -357,14 +361,13 @@
;; preselected option: (selected)
;; changed return value: (value new-value)
;; returns a select input field with several options
(define (make-select-input-fields options . maybe-further-attributes)
(define (make-select-input-field options . maybe-further-attributes)
(let ((name (generate-input-field-name "select")))
(optionals maybe-further-attributes
((attributes XML-attribute?))
(make-input-field
name
(lambda (select)
select) ;FIXME[extension] refer to list elements
identity ;FIXME[extension] refer to list elements
`(select (@ ((name ,name)
,(and attributes (cdr attributes))))
#\newline
@ -440,17 +443,19 @@
,(and button-caption `(value ,button-caption))
,(and attributes (cdr attributes)))))
(define (string-or-symbol? a)
(or (string? a)
(symbol? a)))
(define (make-submit-button . maybe-further-attributes)
(optionals maybe-further-attributes
((button-caption (lambda (a) (or (string? a)
(symbol? a))))
((button-caption string-or-symbol?)
(attributes XML-attribute?))
(make-button "submit" button-caption attributes)))
(define (make-reset-button . maybe-further-attributes)
(optionals maybe-further-attributes
((button-caption (lambda (a) (or (string? a)
(symbol? a))))
((button-caption string-or-symbol?)
(attributes XML-attribute?))
(make-button "reset" button-caption attributes)))