On this page:
make-input
text-input
password-input
checkbox
required
default
to-string
to-number
to-symbol
to-boolean
input-string
input-int
input-symbol
Version: 4.1.5
2.11.4 Predefined Formlets

 (require web-server/formlets/input)

These formlets are the main combinators for form input.

(make-input render)  (formlet/c (or/c false/c binding?))
  render : (string? . -> . xexpr/c)

This formlet is rendered with render, which is passed the input name, and results in the extracted binding.

(text-input [#:value value 
  #:size size 
  #:max-length max-length 
  #:read-only? read-only? 
  #:attributes attrs]) 
  (formlet/c (or/c false/c binding?))
  value : (or/c false/c bytes?) = #f
  size : (or/c false/c exact-nonnegative-integer?) = #f
  max-length : (or/c false/c exact-nonnegative-integer?) = #f
  read-only? : boolean? = #f
  attrs : (listof (list/c symbol? string?)) = empty

This formlet renders using an INPUT element with the TEXT type and the attributes given in the arguments.

(password-input [#:value value 
  #:size size 
  #:max-length max-length 
  #:read-only? read-only? 
  #:attributes attrs]) 
  (formlet/c (or/c false/c binding?))
  value : (or/c false/c bytes?) = #f
  size : (or/c false/c exact-nonnegative-integer?) = #f
  max-length : (or/c false/c exact-nonnegative-integer?) = #f
  read-only? : boolean? = #f
  attrs : (listof (list/c symbol? string?)) = empty

This formlet renders using an INPUT element with the PASSWORD type and the attributes given in the arguments.

(checkbox value checked? [#:attributes attrs])
  (formlet/c (or/c false/c binding?))
  value : bytes?
  checked? : boolean?
  attrs : (listof (list/c symbol? string?)) = empty

This formlet renders using a INPUT elemen with the CHECKBOX type and the attributes given in the arguments.

(required f)  (formlet/c bytes?)
  f : (formlet/c (or/c false/c binding?))

Constructs a formlet that extracts the binding:form-value from the binding produced by f, or errors.

(default def f)  (formlet/c bytes?)
  def : bytes?
  f : (formlet/c (or/c false/c binding?))

Constructs a formlet that extracts the binding:form-value from the binding produced by f, or returns def.

(to-string f)  (formlet/c string?)
  f : (formlet/c bytes?)

Converts f’s output to a string. Equivalent to (cross (pure bytes->string/utf-8) f).

(to-number f)  (formlet/c number?)
  f : (formlet/c string?)

Converts f’s output to a number. Equivalent to (cross (pure string->number) f).

(to-symbol f)  (formlet/c symbol?)
  f : (formlet/c string?)

Converts f’s output to a symbol. Equivalent to (cross (pure string->symbol) f).

(to-boolean f)  (formlet/c boolean?)
  f : (formlet/c bytes?)

Converts f’s output to a boolean, if it is equal to #"on".

input-string : (formlet/c string?)

Equivalent to (to-string (required (text-input))).

input-int : (formlet/c integer?)

Equivalent to (to-number input-string).

input-symbol : (formlet/c symbol?)

Equivalent to (to-symbol input-string).