Using Forms

A form is created using the macro with-fillout-form to establish a form environment around the body of the form.

Within the body, calls to accept-input will create the form fields. For more information see Form Fields.

Form fields can be grouped together using with-form-field-set; see Grouping form fields together - with-form-field-set.

 The following sections give more information about these features:

Creating a form - with-fillout-form

(with-fillout-form (action destination &key keywords) &body body)

Establishes a form environment around the body of a form. For example, a minimal form is:

(with-fillout-form (:post url :stream stream)
  (accept-input 'string "Q2" :label "Name:" :size 36 :stream stream )
  (accept-input 'submit-button "Submit" :stream stream))

This is displayed as:

minimal-form.gif

Parameters

action is either :post, :mail, :get, or :none. The :get action is deprecated and limited to 1024 characters including the rest of the the destination URI.

destination is the URI to which the form values are returned. It must be an HTTP URL for :POST or :GET and a MAILTO URI for :MAIL. DESTINATION can be NIL only when If ACTION is :NONE. DESTINATION may be an interned URI or a string.

Keywords

ENCODING-TYPE is MIME content type to use when return the form values to DESTINATION. ENCODING-TYPE defaults to '(:APPLICATION :X-WWW-FORM-URLENCODED). ENCODING-TYPE should be '(:MULTIPART :FORM-DATA) when used in conjunction with the input type FILE-UPLOAD.

NAME (deprecated in XHTML 1.0) is a name identifying the form element for style sheets. In XHTML, use ID for this purpose.

TARGET specifies the name of a frame where a document is to be opened. The value is a string or a special keyword:

:BLANK - Always load this link into a new, unnamed window

:SELF - Always load this link over yourself :PARENT - Always load this link over your parent (becomes self if your at the top)

:TOP - Always load this link at top level (becomes self if your at the top)

ACCEPT-MEDIA-TYPE is a MIME content type or a list of content types acceptable to the DESTINATION. The default value is :UNKNOWN, establishing the expectation in the client that the destination accepts the media type of document containing the form.

ACCEPT-CHARSET is character encoding or a list of character encodings (see ISO 10646) acceptable to the DESTINATION

CLASS is the class for the element ID is an element identifier.

TITLE is a string used as an element title.

STYLE specifies inline parameters to use in the default style sheet language.

LANGUAGE is the two-digit language code for the displayed content (see RFC 1766)

DIRECTION is the base directionality of neutral text and can be either :LEFT-TO-RIGHT or :RIGHT-TO-LEFT.

EVENTS can be any of the intrinsic events: :KEY-DOWN, :KEY-PRESS, :KEY-UP, :MOUSE-CLICK, :MOUSE-DOUBLE-CLICK, :MOUSE-DOWN, :MOUSE-MOVE, :MOUSE-OUT, :MOUSE-OVER, :MOUSE-UP, :RESET, :SUBMIT.

Grouping form fields together - with-form-field-set

Form fields can be grouped together using with-form-field-set, and a legend added with with-form-field-legend. For example:

(with-form-field-set (:stream stream)
        (with-form-field-legend (:stream stream) (write-string "Please Login:" stream))
        (with-paragraph (:stream stream)
          (accept-input 'string "Q2" :label "Name:" :size 36 :stream stream))
        (with-paragraph (:stream stream)
          (accept-input 'password "Q2" :label "Password:" :stream stream)))

This displays:

fieldset.gif

 


blog comments powered by Disqus