Skip to main content

Module form

Module form 

Source
Expand description

Forms and form fields for handling user input.

This module provides a way to define forms and form fields for handling user input in a web application. It provides a way to create forms from requests, validate the form data, and render the form fields in an HTML form.

§Form derive macro

The easiest way to work with forms in Cot is to use the Form derive macro. Just define a structure that will hold all the form data you need, and derive the Form trait for it.

use cot::form::Form;

#[derive(Form)]
struct MyForm {
    #[form(opts(max_length = 100))]
    name: String,
}

Modules§

fields
Built-in form fields that can be used in a form.

Structs§

FormFieldOptions
Generic options valid for all types of form fields.
FormFieldValue
A value from a form field.
FormFieldValueError
An error that can occur when processing a form field value.

Enums§

FormError
Error occurred while processing a form.
FormErrorTarget
An enum indicating the target of a form validation error.
FormFieldValidationError
An error that can occur when validating a form field.
FormResult
The result of validating a form.

Traits§

AsFormField
A trait for types that can be used as form fields.
DynFormField
A version of FormField that can be used in a dynamic context.
Form
A trait for types that can be used as forms.
FormContext
A trait for form contexts.
FormField
A form field.

Derive Macros§

Form
Derive the Form trait for a struct and create a FormContext for it.