Trait Form

Source
pub trait Form {
    // Required method
    fn new_form(
        field: &str,
        from: Option<&Self>,
    ) -> (FormElements, Box<dyn FormState<Self>>);
}
Expand description

Provides methods for creating forms from a type. All types that can appear as or within such forms must implement this. This is automatically implemented for FormWith<()> so if implementing yourself, focus on that trait.

Required Methods§

Source

fn new_form( field: &str, from: Option<&Self>, ) -> (FormElements, Box<dyn FormState<Self>>)

Generates a form state manager to produce form elements and parse the entered values.

  • field - is the field name, for accessibility using aria-label. <label> isn’t used sometime due to anonymous fields in tuples.

  • from - data used to populate the initial form, for example if creating a form to edit existing data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T: FormWith<()>> Form for T