Skip to main content

Module form

Module form 

Source
Expand description

HTML forms: binding, CSRF, rendering, multipart.

Structs§

BoolToStringTransformer
Maps truthy/falsy view strings to normalized "1" / "0" model values.
CheckboxOptions
Options for FieldKind::Checkbox.
ChoiceEntry
One choice entry: submitted value and display label.
ChoiceOptions
Options for FieldKind::Choice.
ChoiceToValueTransformer
Ensures submitted values are members of a ChoiceOptions list.
CollectionEntryBuilder
Describes fields repeated for each collection index.
CollectionPrototypeMeta
Metadata for progressive-enhancement HTML (no JS framework in core).
CompoundBuilder
Builds nested fields under a dotted name prefix.
Field
One named form field with kind, optional constraints, and current string value.
FileOptions
Options for FieldKind::File.
Form
HTML form with optional CSRF (on by default) and validator bridge.
FormBuilder
Builds a Form.
HiddenOptions
Options for FieldKind::Hidden.
I64ToStringTransformer
Parses and normalizes signed 64-bit integers as decimal strings.
MultipartData
Parsed multipart form: text fields and file uploads.
NumberOptions
Options for FieldKind::Number.
PasswordOptions
Options for FieldKind::Password.
RenderedForm
Escaped HTML produced by crate::Form::render.
TextOptions
Options for FieldKind::Text.
TextareaOptions
Options for FieldKind::Textarea.
UploadedFile
One uploaded file from a multipart/form-data part.

Enums§

FieldConfig
Typed configuration for a field (kind + options).
FieldKind
HTML-oriented field kind used for bind and render.
FileStorage
How an uploaded file is retained after multipart parse.
FormError
Form bind / CSRF / parse failure.
FormStatus
Outcome after Form::handle_request.
NestedData
Nested tree node produced by unflatten_form_data.

Constants§

COLLECTION_PROTOTYPE_INDEX
Placeholder index token used in HTML collection prototypes.
CSRF_FIELD_NAME
Default HTML form field name for the CSRF token (Symfony _token).
DEFAULT_MAX_FILE_SIZE
Default per-file size limit enforced when FileOptions::max_size is unset (2 MiB).
DEFAULT_MAX_MULTIPART_BODY
Default multipart body size limit for crate::parse_multipart (8 MiB).

Traits§

DataTransformer
Converts between the HTML view string and the model string stored on the field.

Functions§

collection_field_name
Builds an indexed collection field name: items[0][name].
collection_indices
Lists numeric indices present for collection in a flat map (items[0][…]).
collection_prototype_field_name
Builds a prototype field name using COLLECTION_PROTOTYPE_INDEX.
escape_attr
Escapes a value for use inside a double-quoted HTML attribute.
escape_html
Escapes text for HTML body content (&, <, >, ", ').
form_csrf
Renders the CSRF hidden input when CSRF is enabled on form.
form_errors
Renders escaped error messages for field from violations.
form_label
Renders a field label (<label for="…">…</label>), HTML-escaped.
form_row
Renders label + widget + errors for one field (all escaped).
form_widget
Renders the field widget only (no label), with values and attributes escaped.
is_multipart
Returns true when content_type is multipart/form-data.
join_multi
Joins multi-values with a single space (stable round-trip for choice multi).
multipart_boundary
Extracts the boundary parameter from a Content-Type header value.
parse_form_body
Parses urlencoded or multipart from a request body using Content-Type.
parse_multipart
Parses a multipart/form-data body.
parse_urlencoded
Parses a URL-encoded form body into string fields (last value wins on duplicates).
parse_urlencoded_multi
Parses a URL-encoded body keeping every value for each key (submission order).
split_multi
Splits a multi-value model/view string on ASCII whitespace.
unflatten_form_data
Builds a nested map from flat urlencoded keys (address.street, items[0][name]).