This is the cl-forms Reference Manual, generated automatically by Declt version 4.0 beta 2 "William Riker" on Sun Sep 15 03:58:11 2024 GMT+0.
cl-forms/cl-forms.asd
cl-forms/src/package.lisp
cl-forms/src/request.lisp
cl-forms/src/themes/theme.lisp
cl-forms/src/themes/default.lisp
cl-forms/src/themes/specials.lisp
cl-forms/src/cl-forms.lisp
cl-forms/src/fields/string.lisp
cl-forms/src/fields/boolean.lisp
cl-forms/src/fields/email.lisp
cl-forms/src/fields/password.lisp
cl-forms/src/fields/url.lisp
cl-forms/src/fields/integer.lisp
cl-forms/src/fields/choice.lisp
cl-forms/src/fields/date.lisp
cl-forms/src/fields/datetime.lisp
cl-forms/src/fields/file.lisp
cl-forms/src/fields/submit.lisp
cl-forms/src/fields/subform.lisp
cl-forms/src/fields/list.lisp
The main system appears first, followed by any subsystem dependency.
cl-forms
A web forms handling library
Mariano Montone <marianomontone@gmail.com>
MIT
# CL-FORMS #
CL-FORMS is a web forms handling library for Common Lisp.
Although it is potentially framework agnostic, it runs on top of Hunchentoot at the moment.
It features:
* Several form field types: String, boolean, integer, email, password fields. And more.
* Custom fields. CL-FORMS is extensible and it is possible to define new field types.
* Server and client side validation
* Rendering backends. Forms can be rendered via CL-WHO, or Djula, or something else; the backend is pluggable. The default renderer is CL-WHO.
* Themes (like Bootstrap)
* Control on rendering and layout.
* Handling of form errors.
* CSRF protection
## Basics ##
Use ‘defform‘ to define a form. Example:
“‘lisp
(defform fields-form (:action "/fields-post")
((name :string :value "")
(ready :boolean :value t)
(sex :choice :choices (list "Male" "Female") :value "Male")
(submit :submit :label "Create")))
“‘
On your web handler, grab the form via ‘find-form‘, select a renderer with ‘with-form-renderer‘and then render the form with ‘render-form‘:
“‘lisp
(let ((form (forms::find-form ’fields-form)))
(forms:with-form-renderer :who
(forms:render-form form))
“‘
To handle the form, grab it via ‘find-form‘ and then call ‘handle-request‘ (you should probably also call ‘validate-form‘ after).
Then bind form fields via either ‘with-form-field-values‘, that binds the form field values; or ‘with-form-fields‘ that binds the form fields.
“‘lisp
(let ((form (forms:find-form ’fields-form)))
(forms::handle-request form)
(forms::with-form-field-values (name ready sex) form
(who:with-html-output (forms.who::*html*)
(:ul
(:li (who:fmt "Name: ~A" name))
(:li (who:fmt "Ready: ~A" ready))
(:li (who:fmt "Sex: ~A" sex))))))
“‘
Plase have a look at the demo sources for more examples of how to use the library
## DEMO ##
There’s a demo included. To run:
“‘lisp
(require :cl-forms.demo)
(forms.test:run-demo)
“‘
alexandria
(system).
cl-ppcre
(system).
hunchentoot
(system).
ironclad
(system).
uuid
(system).
clavier
(system).
fmt
(system).
str
(system).
src
(module).
Modules are listed depth-first from the system components tree.
cl-forms/src
cl-forms
(system).
package.lisp
(file).
request.lisp
(file).
themes
(module).
cl-forms.lisp
(file).
fields
(module).
cl-forms/src/themes
request.lisp
(file).
src
(module).
theme.lisp
(file).
default.lisp
(file).
specials.lisp
(file).
cl-forms/src/fields
cl-forms.lisp
(file).
src
(module).
string.lisp
(file).
boolean.lisp
(file).
email.lisp
(file).
password.lisp
(file).
url.lisp
(file).
integer.lisp
(file).
choice.lisp
(file).
date.lisp
(file).
datetime.lisp
(file).
file.lisp
(file).
hidden.lisp
(file).
submit.lisp
(file).
subform.lisp
(file).
list.lisp
(file).
Files are sorted by type and then listed depth-first from the systems components trees.
cl-forms/cl-forms.asd
cl-forms/src/package.lisp
cl-forms/src/request.lisp
cl-forms/src/themes/theme.lisp
cl-forms/src/themes/default.lisp
cl-forms/src/themes/specials.lisp
cl-forms/src/cl-forms.lisp
cl-forms/src/fields/string.lisp
cl-forms/src/fields/boolean.lisp
cl-forms/src/fields/email.lisp
cl-forms/src/fields/password.lisp
cl-forms/src/fields/url.lisp
cl-forms/src/fields/integer.lisp
cl-forms/src/fields/choice.lisp
cl-forms/src/fields/date.lisp
cl-forms/src/fields/datetime.lisp
cl-forms/src/fields/file.lisp
cl-forms/src/fields/hidden.lisp
cl-forms/src/fields/submit.lisp
cl-forms/src/fields/subform.lisp
cl-forms/src/fields/list.lisp
cl-forms/src/request.lisp
package.lisp
(file).
src
(module).
request-post-parameters
(generic function).
cl-forms/src/themes/theme.lisp
themes
(module).
form-theme
(class).
cl-forms/src/themes/default.lisp
theme.lisp
(file).
themes
(module).
default-form-theme
(class).
cl-forms/src/themes/specials.lisp
default.lisp
(file).
themes
(module).
*form-theme*
(special variable).
cl-forms/src/cl-forms.lisp
themes
(module).
src
(module).
*base64-encode*
(special variable).
add-field
(function).
add-form-error
(function).
defform
(macro).
defform-builder
(macro).
field-accessor
(reader method).
(setf field-accessor)
(writer method).
field-formatter
(reader method).
(setf field-formatter)
(writer method).
field-label
(method).
field-parser
(reader method).
(setf field-parser)
(writer method).
field-reader
(method).
field-valid-p
(method).
field-value
(method).
field-value
(method).
(setf field-value)
(method).
field-writer
(method).
fill-form-from-model
(function).
fill-model-from-form
(function).
find-form
(function).
form
(class).
form-errors
(reader method).
(setf form-errors)
(writer method).
form-field
(class).
form-fields
(reader method).
(setf form-fields)
(writer method).
form-valid-p
(function).
format-field-value
(generic function).
format-field-value-to-string
(function).
get-field
(function).
get-field-value
(function).
get-form
(function).
handle-request
(function).
initialize-instance
(method).
make-formatter
(function).
print-object
(method).
print-object
(method).
remove-field
(function).
render-field
(function).
render-field-errors
(function).
render-field-label
(function).
render-field-widget
(function).
render-form
(function).
render-form-end
(function).
render-form-errors
(function).
render-form-start
(function).
set-field-value
(function).
validate-form
(function).
with-form
(macro).
with-form-field-values
(macro).
with-form-fields
(macro).
with-form-renderer
(macro).
with-form-template
(macro).
with-form-theme
(macro).
%collect-replace-fields
(function).
*default-form-renderer*
(special variable).
*field-path*
(special variable).
*field-required-message*
(special variable).
*form*
(special variable).
*form-renderer*
(special variable).
call-with-form
(function).
call-with-form-renderer
(method).
call-with-form-theme
(function).
check-duplicate-fields
(function).
client-validation
(reader method).
(setf client-validation)
(writer method).
collect-replace-fields
(function).
display-errors
(reader method).
(setf display-errors)
(writer method).
empty-value-p
(function).
field-add-to-path
(generic function).
field-constraints
(reader method).
(setf field-constraints)
(writer method).
field-default-value
(reader method).
(setf field-default-value)
(writer method).
field-disabled-p
(reader method).
(setf field-disabled-p)
(writer method).
field-form
(reader method).
(setf field-form)
(writer method).
field-help-text
(reader method).
(setf field-help-text)
(writer method).
field-invalid-message
(reader method).
(setf field-invalid-message)
(writer method).
field-name
(reader method).
(setf field-name)
(writer method).
field-placeholder
(reader method).
(setf field-placeholder)
(writer method).
field-read-from-request
(generic function).
field-read-only-p
(reader method).
(setf field-read-only-p)
(writer method).
field-render-label-p
(method).
field-request-name
(function).
field-required-message
(reader method).
(setf field-required-message)
(writer method).
field-required-p
(reader method).
(setf field-required-p)
(writer method).
field-trim-p
(reader method).
(setf field-trim-p)
(writer method).
field-validation-triggers
(reader method).
(setf field-validation-triggers)
(writer method).
field-validator
(class).
form-action
(reader method).
(setf form-action)
(writer method).
form-csrf-field-name
(reader method).
(setf form-csrf-field-name)
(writer method).
form-csrf-protection-p
(reader method).
(setf form-csrf-protection-p)
(writer method).
form-enctype
(reader method).
(setf form-enctype)
(writer method).
form-id
(reader method).
(setf form-id)
(writer method).
form-method
(reader method).
(setf form-method)
(writer method).
form-model
(reader method).
(setf form-model)
(writer method).
form-name
(reader method).
(setf form-name)
(writer method).
form-session-csrf-entry
(method).
get-form-session-csrf-token
(method).
make-csrf-token
(method).
make-form
(function).
make-form-field
(generic function).
make-form-fields
(function).
post-parameters
(function).
render-field-request-name
(function).
renderer-render-field
(generic function).
renderer-render-field-errors
(generic function).
renderer-render-field-label
(generic function).
renderer-render-field-widget
(generic function).
renderer-render-form
(generic function).
renderer-render-form-end
(generic function).
renderer-render-form-errors
(generic function).
renderer-render-form-start
(generic function).
set-form-session-csrf-token
(method).
validate-form-field
(generic function).
validator-field
(reader method).
(setf validator-field)
(writer method).
cl-forms/src/fields/string.lisp
fields
(module).
string-form-field
(class).
text-form-field
(class).
field-read-from-request
(method).
make-form-field
(method).
make-form-field
(method).
make-form-field
(method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/boolean.lisp
fields
(module).
boolean-form-field
(class).
format-field-value
(method).
field-read-from-request
(method).
field-required-p
(method).
make-form-field
(method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/email.lisp
fields
(module).
email-form-field
(class).
field-read-from-request
(method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/password.lisp
fields
(module).
password-form-field
(class).
field-read-from-request
(method).
make-form-field
(method).
cl-forms/src/fields/url.lisp
fields
(module).
url-form-field
(class).
field-read-from-request
(method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/integer.lisp
fields
(module).
integer-form-field
(class).
field-read-from-request
(method).
make-form-field
(method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/choice.lisp
fields
(module).
choice-form-field
(class).
initialize-instance
(method).
%validate
(method).
alistp
(function).
choice-field-validator
(class).
field-choices
(method).
(setf field-choices)
(writer method).
field-choices-alist
(method).
field-expanded
(reader method).
(setf field-expanded)
(writer method).
field-hash-function
(reader method).
(setf field-hash-function)
(writer method).
field-key-and-value
(method).
field-key-reader
(reader method).
(setf field-key-reader)
(writer method).
field-keys-and-values
(method).
field-multiple
(reader method).
(setf field-multiple)
(writer method).
field-preferred-choices
(reader method).
(setf field-preferred-choices)
(writer method).
field-read-from-request
(method).
field-test
(reader method).
(setf field-test)
(writer method).
make-form-field
(method).
make-form-field
(method).
string-choice-form-field
(class).
use-key-as-value
(reader method).
(setf use-key-as-value)
(writer method).
cl-forms/src/fields/date.lisp
fields
(module).
date-form-field
(class).
format-field-value
(method).
%validate
(method).
+default-date-format+
(special variable).
date-format
(reader method).
date-format
(reader method).
(setf date-format)
(writer method).
(setf date-format)
(writer method).
date-max
(reader method).
(setf date-max)
(writer method).
date-min
(reader method).
(setf date-min)
(writer method).
date-validator
(class).
field-read-from-request
(method).
field-widget
(reader method).
(setf field-widget)
(writer method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/datetime.lisp
fields
(module).
datetime-form-field
(class).
format-field-value
(method).
%validate
(method).
+default-datetime-format+
(special variable).
datetime-format
(reader method).
datetime-format
(reader method).
(setf datetime-format)
(writer method).
(setf datetime-format)
(writer method).
datetime-max
(reader method).
(setf datetime-max)
(writer method).
datetime-min
(reader method).
(setf datetime-min)
(writer method).
datetime-validator
(class).
field-read-from-request
(method).
field-widget
(reader method).
(setf field-widget)
(writer method).
make-form-field
(method).
validate-form-field
(method).
cl-forms/src/fields/file.lisp
fields
(module).
file-form-field
(class).
download-link
(method).
field-read-from-request
(method).
field-read-from-request
(method).
file-accept
(reader method).
(setf file-accept)
(writer method).
file-content-type
(reader method).
(setf file-content-type)
(writer method).
file-name
(reader method).
(setf file-name)
(writer method).
file-path
(reader method).
(setf file-path)
(writer method).
make-form-field
(method).
make-form-field
(method).
multiple-p
(reader method).
(setf multiple-p)
(writer method).
stateful-file-field
(class).
upload-handler
(reader method).
(setf upload-handler)
(writer method).
cl-forms/src/fields/submit.lisp
fields
(module).
submit-form-field
(class).
field-read-from-request
(method).
field-render-label-p
(method).
make-form-field
(method).
cl-forms/src/fields/subform.lisp
fields
(module).
subform-form-field
(class).
field-add-to-path
(method).
field-read-from-request
(method).
field-subform
(method).
field-subform-builder
(reader method).
(setf field-subform-builder)
(writer method).
field-subform-name
(reader method).
(setf field-subform-name)
(writer method).
make-form-field
(method).
subform-builder
(method).
cl-forms/src/fields/list.lisp
fields
(module).
list-form-field
(class).
add-button-p
(reader method).
(setf add-button-p)
(writer method).
empty-item-predicate
(reader method).
(setf empty-item-predicate)
(writer method).
field-read-from-request
(method).
list-field-type
(reader method).
(setf list-field-type)
(writer method).
list-field-values
(function).
make-form-field
(method).
remove-button-p
(reader method).
(setf remove-button-p)
(writer method).
Packages are listed by definition order.
cl-forms
forms
common-lisp
.
*base64-encode*
(special variable).
add-field
(function).
add-form-error
(function).
boolean-form-field
(class).
choice-form-field
(class).
date-form-field
(class).
datetime-form-field
(class).
defform
(macro).
defform-builder
(macro).
email-form-field
(class).
field-accessor
(generic reader).
(setf field-accessor)
(generic writer).
field-formatter
(generic reader).
(setf field-formatter)
(generic writer).
field-label
(generic function).
field-parser
(generic reader).
(setf field-parser)
(generic writer).
field-reader
(generic function).
field-valid-p
(generic function).
field-value
(generic function).
(setf field-value)
(generic function).
field-writer
(generic function).
file-form-field
(class).
fill-form-from-model
(function).
fill-model-from-form
(function).
find-form
(function).
form
(class).
form-errors
(generic reader).
(setf form-errors)
(generic writer).
form-field
(class).
form-fields
(generic reader).
(setf form-fields)
(generic writer).
form-valid-p
(function).
format-field-value
(generic function).
format-field-value-to-string
(function).
get-field
(function).
get-field-value
(function).
get-form
(function).
handle-request
(function).
hidden-form-field
(class).
integer-form-field
(class).
list-form-field
(class).
make-formatter
(function).
password-form-field
(class).
remove-field
(function).
render-field
(function).
render-field-errors
(function).
render-field-label
(function).
render-field-widget
(function).
render-form
(function).
render-form-end
(function).
render-form-errors
(function).
render-form-start
(function).
set-field-value
(function).
string-form-field
(class).
subform-form-field
(class).
submit-form-field
(class).
text-form-field
(class).
url-form-field
(class).
validate-form
(function).
with-form
(macro).
with-form-field-values
(macro).
with-form-fields
(macro).
with-form-renderer
(macro).
with-form-template
(macro).
with-form-theme
(macro).
%collect-replace-fields
(function).
*default-form-renderer*
(special variable).
*field-path*
(special variable).
*field-required-message*
(special variable).
*form*
(special variable).
*form-renderer*
(special variable).
*form-theme*
(special variable).
+default-date-format+
(special variable).
+default-datetime-format+
(special variable).
add-button-p
(generic reader).
(setf add-button-p)
(generic writer).
alistp
(function).
call-with-form
(function).
call-with-form-renderer
(generic function).
call-with-form-theme
(function).
check-duplicate-fields
(function).
choice-field-validator
(class).
client-validation
(generic reader).
(setf client-validation)
(generic writer).
collect-replace-fields
(function).
date-format
(generic reader).
(setf date-format)
(generic writer).
date-max
(generic reader).
(setf date-max)
(generic writer).
date-min
(generic reader).
(setf date-min)
(generic writer).
date-validator
(class).
datetime-format
(generic reader).
(setf datetime-format)
(generic writer).
datetime-max
(generic reader).
(setf datetime-max)
(generic writer).
datetime-min
(generic reader).
(setf datetime-min)
(generic writer).
datetime-validator
(class).
default-form-theme
(class).
display-errors
(generic reader).
(setf display-errors)
(generic writer).
download-link
(generic function).
empty-item-predicate
(generic reader).
(setf empty-item-predicate)
(generic writer).
empty-value-p
(function).
field-add-to-path
(generic function).
field-choices
(generic function).
(setf field-choices)
(generic writer).
field-choices-alist
(generic function).
field-constraints
(generic reader).
(setf field-constraints)
(generic writer).
field-default-value
(generic reader).
(setf field-default-value)
(generic writer).
field-disabled-p
(generic reader).
(setf field-disabled-p)
(generic writer).
field-expanded
(generic reader).
(setf field-expanded)
(generic writer).
field-form
(generic reader).
(setf field-form)
(generic writer).
field-hash-function
(generic reader).
(setf field-hash-function)
(generic writer).
field-help-text
(generic reader).
(setf field-help-text)
(generic writer).
field-invalid-message
(generic reader).
(setf field-invalid-message)
(generic writer).
field-key-and-value
(generic function).
field-key-reader
(generic reader).
(setf field-key-reader)
(generic writer).
field-keys-and-values
(generic function).
field-multiple
(generic reader).
(setf field-multiple)
(generic writer).
field-name
(generic reader).
(setf field-name)
(generic writer).
field-placeholder
(generic reader).
(setf field-placeholder)
(generic writer).
field-preferred-choices
(generic reader).
(setf field-preferred-choices)
(generic writer).
field-read-from-request
(generic function).
field-read-only-p
(generic reader).
(setf field-read-only-p)
(generic writer).
field-render-label-p
(generic function).
field-request-name
(function).
field-required-message
(generic reader).
(setf field-required-message)
(generic writer).
field-required-p
(generic function).
(setf field-required-p)
(generic writer).
field-subform
(generic function).
field-subform-builder
(generic reader).
(setf field-subform-builder)
(generic writer).
field-subform-name
(generic reader).
(setf field-subform-name)
(generic writer).
field-test
(generic reader).
(setf field-test)
(generic writer).
field-trim-p
(generic reader).
(setf field-trim-p)
(generic writer).
field-validation-triggers
(generic reader).
(setf field-validation-triggers)
(generic writer).
field-validator
(class).
field-widget
(generic reader).
(setf field-widget)
(generic writer).
file-accept
(generic reader).
(setf file-accept)
(generic writer).
file-content-type
(generic reader).
(setf file-content-type)
(generic writer).
file-name
(generic reader).
(setf file-name)
(generic writer).
file-path
(generic reader).
(setf file-path)
(generic writer).
form-action
(generic reader).
(setf form-action)
(generic writer).
form-csrf-field-name
(generic reader).
(setf form-csrf-field-name)
(generic writer).
form-csrf-protection-p
(generic reader).
(setf form-csrf-protection-p)
(generic writer).
form-enctype
(generic reader).
(setf form-enctype)
(generic writer).
form-id
(generic reader).
(setf form-id)
(generic writer).
form-method
(generic reader).
(setf form-method)
(generic writer).
form-model
(generic reader).
(setf form-model)
(generic writer).
form-name
(generic reader).
(setf form-name)
(generic writer).
form-session-csrf-entry
(generic function).
form-theme
(class).
get-form-session-csrf-token
(generic function).
list-field-type
(generic reader).
(setf list-field-type)
(generic writer).
list-field-values
(function).
make-csrf-token
(generic function).
make-form
(function).
make-form-field
(generic function).
make-form-fields
(function).
multiple-p
(generic reader).
(setf multiple-p)
(generic writer).
post-parameters
(function).
remove-button-p
(generic reader).
(setf remove-button-p)
(generic writer).
render-field-request-name
(function).
renderer-render-field
(generic function).
renderer-render-field-errors
(generic function).
renderer-render-field-label
(generic function).
renderer-render-field-widget
(generic function).
renderer-render-form
(generic function).
renderer-render-form-end
(generic function).
renderer-render-form-errors
(generic function).
renderer-render-form-start
(generic function).
request-post-parameters
(generic function).
set-form-session-csrf-token
(generic function).
stateful-file-field
(class).
string-choice-form-field
(class).
subform-builder
(generic function).
upload-handler
(generic reader).
(setf upload-handler)
(generic writer).
use-key-as-value
(generic reader).
(setf use-key-as-value)
(generic writer).
validate-form-field
(generic function).
validator-field
(generic reader).
(setf validator-field)
(generic writer).
Definitions are sorted by export status, category, package, and then by lexicographic order.
Whether to encode form parameters in base64 or not.
Define a form at top-level.
ARGS are the arguments passed to FORM class via MAKE-INSTANCE.
FIELDS are the form field specs.
@lisp
(forms:defform client-validated-form (:action "/client-validation-post"
:client-validation t)
((name :string :value "" :constraints (list (clavier:is-a-string)
(clavier:not-blank)
(clavier:len :max 5))
:validation-triggers ’(:focusin))
(single :boolean :value t)
(sex :choice :choices (list "Male" "Female") :value "Male")
(age :integer :constraints (list (clavier:is-an-integer)
(clavier:greater-than -1)
(clavier:less-than 200)))
(email :email)
(submit :submit :label "Create")))
@end lisp
Registers a function with arguments ARGS and body BODY as a form builder.
BODY is expected to instantiate a FORM object using ARGS in some way.
FORM-NAME is the symbol under which the FORM is registered.
Use FIND-FORM with FORM-NAME and expected arguments to obtain the registered form.
Bind *FORM* to FORM and evaluate BODY in that context.
Bind the value of FIELDS in FORM.
Example:
@lisp
(with-form-field-values (name) form
(print name))
@end lisp
Bind FIELDS to the form fields in FORM.
Example:
@lisp
(with-form-fields (name) form
(print (field-value name)))
@end lisp
Also see: WITH-FORM-FIELD-VALUES
Bind *FORM-RENDERER* to RENDERER and evaluate BODY in that context.
Define a FORM named FORM-NAME and render it at the same time.
Bind *FORM-THEME* to FORM-THEME and evaluate BODY in that context.
Add an error on FIELD
Fill a FORM from a MODEL.
Read MODEL using FORM accessors and set the FORM field values.
Set a MODEL’s values from FORM field values.
Get the form named NAME.
ARGS is the list of arguments to pass to a possible form builder function.
See: DEFFORM-BUILDER macro.
Populates FORM from parameters in HTTP request. After this, the form field contains values, but they are not validated. To validate call VALIDATE-FORM after.
Create a field formatter. SYMBOL is the function to call.
Render form FIELD, both label and widget.
Render the validation errors associated with FIELD.
Render the label of FIELD.
Render FIELD widget.
Top level function to render the web form FORM. *FORM-RENDERER* and *FORM-THEME* need to be bound. See: WITH-FORM-RENDERER, WITH-FORM-THEME
Render the end of the web form FORM.
Render a section for displaying form validation errors.
Render only the beggining of the web form FORM.
Use RENDER-FIELD, RENDER-FIELD-LABEL, etc manually, after.
Validates a form. Usually called after HANDLE-REQUEST. Returns multiple values; first value is true if the form is valid; second value a list of errors. The list of errors is an association list with elements (<field> . <field errors strings list>).
form-field
)) ¶form-field
)) ¶The field accessor to the underlying model
form-field
)) ¶form-field
)) ¶The field formatter. The function takes two arguments, a VALUE and STREAM to format it into.
form-field
)) ¶form-field
)) ¶form-field
)) ¶Custom field value parser
form-field
)) ¶form-field
) &optional form) ¶Determines if a field is valid. This method assumes the form has already been validated via validate-form.
form-field
)) ¶form-field
)) ¶form-field
)) ¶form-field
)) ¶datetime-form-field
) value &optional stream) ¶date-form-field
) value &optional stream) ¶boolean-form-field
) value &optional stream) ¶form-field
) field-value &optional stream) ¶form-field
) field-value &optional stream) ¶choice-form-field
) &rest initargs) ¶form-field
) stream) ¶A boolean input
A multi-purpose field used to allow the user to "choose" one or more options. It can be rendered as a select tag, radio buttons, or checkboxes. NOTE: the defaults of this field type are too complicated for just working with string choices. STRING-CHOICE-FIELD is more convenient for that.
field-choices
.
(setf field-choices)
.
field-choices-alist
.
(setf field-expanded)
.
field-expanded
.
(setf field-hash-function)
.
field-hash-function
.
field-key-and-value
.
(setf field-key-reader)
.
field-key-reader
.
field-keys-and-values
.
(setf field-multiple)
.
field-multiple
.
(setf field-preferred-choices)
.
field-preferred-choices
.
field-read-from-request
.
(setf field-test)
.
field-test
.
initialize-instance
.
(setf use-key-as-value)
.
use-key-as-value
.
An alist with the choices. Or a function with which to obtain the choices.
(or list symbol function)
:choices
If this option is specified, then a sub-set of all of the options will be moved to the top of the select menu.
:preferred-choices
If set to true, radio buttons or checkboxes will be rendered (depending on the multiple value). If false, a select element will be rendered.
:expanded
If true, the user will be able to select multiple options (as opposed to choosing just one option). Depending on the value of the expanded option, this will render either a select tag or checkboxes if true and a select tag or radio buttons if false.
:multiple
Function to read the option key from the request
(function identity)
:key-reader
The function to use for choices key
(function sxhash)
:hash-function
Function to test equality between choices
(function eql)
:test
When T, use the key/s of the field as value of the field when it is read from request
:use-key-as-value
A date input field
Initarg | Value |
---|---|
:placeholder | yyyy-mm-dd |
:date-min
:date-max
cl-forms::+default-date-format+
:date-format
:widget
A date input field
Initarg | Value |
---|---|
:placeholder | yyyy-mm-ddthh:mm:ss |
:min
:max
cl-forms::+default-datetime-format+
:datetime-format
:widget
A string input field
A file input field
If this fields handles multiple file uploads
:multiple-p
:path
:file-name
:content-type
Function that handles the file upload
:upload-handler
Files accepted. See https://www.w3schools.com/tags/att_input_accept.asp
(or null string)
:accept
A form
(setf client-validation)
.
client-validation
.
(setf display-errors)
.
display-errors
.
(setf form-action)
.
form-action
.
(setf form-csrf-field-name)
.
form-csrf-field-name
.
(setf form-csrf-protection-p)
.
form-csrf-protection-p
.
(setf form-enctype)
.
form-enctype
.
(setf form-errors)
.
form-errors
.
(setf form-fields)
.
form-fields
.
(setf form-id)
.
form-id
.
(setf form-method)
.
form-method
.
(setf form-model)
.
form-model
.
(setf form-name)
.
form-name
.
form-session-csrf-entry
.
get-form-session-csrf-token
.
initialize-instance
.
make-csrf-token
.
print-object
.
set-form-session-csrf-token
.
The form id
string
(string (gensym))
:id
The form name
symbol
(error "provide a name for the form")
:name
The form action
(or null string)
:action
The form method
common-lisp
.
(member :get :post)
:post
:method
Form encoding type. i.e. Use multipart/form-data for file uploads
(or null string)
:enctype
Form fields
:fields
The form model object
:model
T when csrf protection is enabled
boolean
:csrf-protection
csrf field name
(or null string)
"_token"
:csrf-field-name
Form errors after validation. An association list with elements (<field> . <field errors strings list>).
list
A list containing the places where to display errors. Valid options are :list and :inline
list
(list :list :inline)
:display-errors
When T, form client validation is enabled
boolean
:client-validation
A form field
(setf field-accessor)
.
field-accessor
.
(setf field-constraints)
.
field-constraints
.
(setf field-default-value)
.
field-default-value
.
(setf field-disabled-p)
.
field-disabled-p
.
(setf field-form)
.
field-form
.
(setf field-formatter)
.
field-formatter
.
(setf field-help-text)
.
field-help-text
.
(setf field-invalid-message)
.
field-invalid-message
.
field-label
.
(setf field-name)
.
field-name
.
(setf field-parser)
.
field-parser
.
(setf field-placeholder)
.
field-placeholder
.
(setf field-read-only-p)
.
field-read-only-p
.
field-reader
.
field-render-label-p
.
(setf field-required-message)
.
field-required-message
.
(setf field-required-p)
.
field-required-p
.
(setf field-trim-p)
.
field-trim-p
.
field-valid-p
.
(setf field-validation-triggers)
.
field-validation-triggers
.
(setf field-value)
.
field-value
.
field-value
.
field-writer
.
format-field-value
.
format-field-value
.
print-object
.
validate-form-field
.
validate-form-field
.
The field name
symbol
(error "provide the field name")
:name
The field label
(or null string)
:label
Field value
:value
Value to use when the field value is nil
:default-value
Field placeholder (text that appears when the field is empty)
(or null string)
:placeholder
Field help text
(or null string)
:help-text
Custom field value parser
(or null symbol function)
:parser
The field formatter. The function takes two arguments, a VALUE and STREAM to format it into.
common-lisp
.
(or null symbol function)
:formatter
A list of CLAVIER validators.
:constraints
Whether the field is required
boolean
t
:required-p
Message to display when field is required
(or null string)
cl-forms::*field-required-message*
:required-message
Message to display when field is invalid
(or null string function)
:invalid-message
Whether the field is read only
boolean
:read-only-p
Whether the field is disabled
boolean
:disabled-p
The field accessor to the underlying model
(or null symbol)
:accessor
The function to use to read from the underlying model
(or null symbol function)
:reader
The function to use to write to underlying model
(or null symbol function)
:writer
Trim the input
boolean
t
:trim-p
Client side validation triggers. A list of :change, :focus, :focusout, :focusin, etc
:validation-triggers
The form the field belongs to
(or null cl-forms:form)
:form
An integer input field
A field that contains a list of elements (either other fields or subforms)
The list elements type.
common-lisp
.
function
(error "provide the list type via :type")
:type
A predicate that tells when a list item is considered empty, and so it is removed from the list
(or null function)
:empty-item-predicate
Whether have a list ’ADD’ button or not
boolean
t
:add-button
Whether add an item removal button or not
boolean
t
:remove-button
A password input field
A string input field
A field that contains a form (subform)
A submit input button
Initarg | Value |
---|---|
:required-p | nil |
A text field. Renders as a text area
An url input field
The default form renderer. The default renderer is CL-WHO.
The default message to displayed when a field is required.
The current form.
The current form renderer. Bind using WITH-FORM-RENDERER.
The theme with which to render forms. Default is DEFAULT-FORM-THEME .
Returns the actual values of a list field
list-form-field
)) ¶list-form-field
)) ¶Whether have a list ’ADD’ button or not
date-validator
)) ¶automatically generated reader method
date-form-field
)) ¶automatically generated reader method
date-validator
)) ¶automatically generated writer method
date-form-field
)) ¶automatically generated writer method
date-form-field
)) ¶automatically generated reader method
date-form-field
)) ¶automatically generated writer method
date-form-field
)) ¶automatically generated reader method
date-form-field
)) ¶automatically generated writer method
datetime-validator
)) ¶automatically generated reader method
datetime-form-field
)) ¶automatically generated reader method
datetime-validator
)) ¶automatically generated writer method
datetime-form-field
)) ¶automatically generated writer method
datetime-form-field
)) ¶automatically generated reader method
datetime-form-field
)) ¶automatically generated writer method
datetime-form-field
)) ¶automatically generated reader method
datetime-form-field
)) ¶automatically generated writer method
stateful-file-field
)) ¶list-form-field
)) ¶list-form-field
)) ¶A predicate that tells when a list item is considered empty, and so it is removed from the list
subform-form-field
) form &optional path) ¶choice-form-field
)) ¶choice-form-field
)) ¶An alist with the choices. Or a function with which to obtain the choices.
choice-form-field
)) ¶form-field
)) ¶form-field
)) ¶A list of CLAVIER validators.
form-field
)) ¶form-field
)) ¶Value to use when the field value is nil
form-field
)) ¶form-field
)) ¶Whether the field is disabled
choice-form-field
)) ¶choice-form-field
)) ¶If set to true, radio buttons or checkboxes will be rendered (depending on the multiple value). If false, a select element will be rendered.
form-field
)) ¶form-field
)) ¶The form the field belongs to
form
.
choice-form-field
)) ¶choice-form-field
)) ¶The function to use for choices key
form-field
)) ¶form-field
)) ¶Field help text
form-field
)) ¶form-field
)) ¶Message to display when field is invalid
choice-form-field
)) ¶choice-form-field
)) ¶choice-form-field
)) ¶Function to read the option key from the request
choice-form-field
)) ¶choice-form-field
)) ¶choice-form-field
)) ¶If true, the user will be able to select multiple options (as opposed to choosing just one option). Depending on the value of the expanded option, this will render either a select tag or checkboxes if true and a select tag or radio buttons if false.
form-field
)) ¶form-field
)) ¶The field name
name
.
form-field
)) ¶form-field
)) ¶Field placeholder (text that appears when the field is empty)
choice-form-field
)) ¶choice-form-field
)) ¶If this option is specified, then a sub-set of all of the options will be moved to the top of the select menu.
list-form-field
) form parameters) ¶subform-form-field
) form parameters) ¶submit-form-field
) form parameters) ¶hidden-form-field
) form parameters) ¶stateful-file-field
) form parameters) ¶file-form-field
) form parameters) ¶datetime-form-field
) form parameters) ¶date-form-field
) form parameters) ¶choice-form-field
) form parameters) ¶integer-form-field
) form parameters) ¶url-form-field
) form parameters) ¶password-form-field
) form parameters) ¶email-form-field
) form parameters) ¶boolean-form-field
) form parameters) ¶string-form-field
) form parameters) ¶Use the parser function after reading the value from the request
form-field
)) ¶form-field
)) ¶Whether the field is read only
submit-form-field
)) ¶hidden-form-field
)) ¶form-field
)) ¶form-field
)) ¶form-field
)) ¶Message to display when field is required
boolean-form-field
)) ¶form-field
)) ¶Whether the field is required
form-field
)) ¶Whether the field is required
subform-form-field
)) ¶subform-form-field
)) ¶automatically generated reader method
subform-form-field
)) ¶automatically generated writer method
subform-form-field
)) ¶automatically generated reader method
subform-form-field
)) ¶automatically generated writer method
choice-form-field
)) ¶choice-form-field
)) ¶Function to test equality between choices
test
.
form-field
)) ¶form-field
)) ¶Trim the input
trim
.
form-field
)) ¶form-field
)) ¶Client side validation triggers. A list of :change, :focus, :focusout, :focusin, etc
datetime-form-field
)) ¶automatically generated reader method
date-form-field
)) ¶automatically generated reader method
datetime-form-field
)) ¶automatically generated writer method
date-form-field
)) ¶automatically generated writer method
file-form-field
)) ¶file-form-field
)) ¶Files accepted. See https://www.w3schools.com/tags/att_input_accept.asp
file-form-field
)) ¶automatically generated reader method
file-form-field
)) ¶automatically generated writer method
file-form-field
)) ¶automatically generated reader method
file-form-field
)) ¶automatically generated writer method
file-form-field
)) ¶automatically generated reader method
file-form-field
)) ¶automatically generated writer method
list-form-field
)) ¶list-form-field
)) ¶The list elements type.
(eql :subform)
) &rest args) ¶(eql :submit)
) &rest args) ¶(eql :hidden)
) &rest args) ¶(eql :datetime)
) &rest args) ¶(eql :string-choice)
) &rest args) ¶(eql :choice)
) &rest args) ¶(eql :integer)
) &rest args) ¶(eql integer)
) &rest args) ¶(eql :password)
) &rest args) ¶(eql :email)
) &rest args) ¶(eql :boolean)
) &rest args) ¶(eql boolean)
) &rest args) ¶(eql cl-forms::text)
) &rest args) ¶(eql :text)
) &rest args) ¶(eql :string)
) &rest args) ¶(eql string)
) &rest args) ¶Provide a good error message when a field cannot be built
file-form-field
)) ¶file-form-field
)) ¶If this fields handles multiple file uploads
list-form-field
)) ¶list-form-field
)) ¶Whether add an item removal button or not
request
)) ¶subform-form-field
)) ¶file-form-field
)) ¶file-form-field
)) ¶Function that handles the file upload
choice-form-field
)) ¶choice-form-field
)) ¶When T, use the key/s of the field as value of the field when it is read from request
datetime-form-field
)) ¶date-form-field
)) ¶integer-form-field
)) ¶url-form-field
)) ¶email-form-field
)) ¶boolean-form-field
)) ¶string-form-field
)) ¶form-field
)) ¶form-field
)) ¶field-validator
)) ¶field-validator
)) ¶The validator field
choice-field-validator
) object &rest args) ¶clavier
.
date-validator
) object &rest args) ¶clavier
.
datetime-validator
) object &rest args) ¶clavier
.
Initarg | Value |
---|---|
:message | the option is not valid |
A date validator. TODO: should perhaps be part of clavier validators
validator
.
Initarg | Value |
---|---|
:message | (lambda (validator object) (declare (ignorable validator object)) the date is invalid) |
cl-forms::+default-date-format+
:date-format
A datetime validator. TODO: should perhaps be part of clavier validators
validator
.
Initarg | Value |
---|---|
:message | (lambda (validator object) (declare (ignorable validator object)) the datetime is invalid) |
cl-forms::+default-datetime-format+
:datetime-format
The default form theme
Generic field validator. Needs a field to be initialized.
validator
.
The validator field
(error "provide the field")
:field
An stateful file field is a file field that mantains its value (the uploaded file data) and renders the the uploaded file download link and a file upload widget
Function to generate the download link to the file
(or null string symbol function)
:download-link
A choice field for working with string options
Initarg | Value |
---|---|
:test | (quote string=) |
:hash-function | (quote identity) |
:use-key-as-value | t |
Jump to: | %
(
A C D E F G H I L M P R S U V W |
---|
Jump to: | %
(
A C D E F G H I L M P R S U V W |
---|
Jump to: | *
+
A C D E F H I K L M N P R S T U V W |
---|
Jump to: | *
+
A C D E F H I K L M N P R S T U V W |
---|
Jump to: | B C D E F H I L M P R S T U |
---|
Jump to: | B C D E F H I L M P R S T U |
---|