pub trait FormExt {
// Required method
fn to_metadata(&self) -> FormMetadata;
}Expand description
Extension trait for Form to extract metadata (Week 5 Day 1)
This trait provides the to_metadata() method that converts a Form
into a serializable FormMetadata structure.
Required Methods§
Sourcefn to_metadata(&self) -> FormMetadata
fn to_metadata(&self) -> FormMetadata
Extract serializable metadata from the form
This method creates a FormMetadata structure containing all
information needed to render the form on the client-side.
§Examples
use reinhardt_forms::{Form, CharField, Field};
use reinhardt_forms::wasm_compat::{FormMetadata, FormExt};
let mut form = Form::new();
form.add_field(Box::new(CharField::new("email".to_string())));
let metadata: FormMetadata = form.to_metadata();
assert_eq!(metadata.fields.len(), 1);
assert_eq!(metadata.fields[0].name, "email");