Skip to main content

FormFields

Trait FormFields 

Source
pub trait FormFields {
    type Field;
    type Keys;

    // Required method
    fn keys() -> Self::Keys;
}
Expand description

The fields a submission’s errors name: a record form’s or a form input’s, or the panel’s own form keys (String).

The RecordForm, ModelForm and FormInput derives implement it, so an app keys its errors by its form, FieldErrors<UserForm>, and picks a field by its name, errors.add(|f| f.age, ..). The field enum the derive writes, UserFormField, is the transport: the key the panel posts and renders an error under, which an app’s code never needs to spell.

Required Associated Types§

Source

type Field

What an error names: one variant per field, or a form key.

Source

type Keys

One key per field, named like the field, which an error picks a field from: the derive writes UserFormKeys, holding age: UserFormField::Age; a form with no field has ().

Required Methods§

Source

fn keys() -> Self::Keys

The keys.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FormFields for ()

No input: an action runs on its button.

Source§

type Field = !

Source§

type Keys = ()

Source§

fn keys() -> Self::Keys

Source§

impl FormFields for String

The panel’s own errors, keyed by the form key they render under.

Implementors§