pub struct Form { /* private fields */ }Expand description
A form that aggregates multiple FormFields. Since FormField clones
share their underlying atoms (D116 Phase 28 Step 8), Form itself is
just a Vec<FormField> — no separate reactive plumbing needed at the
Form level; every method here is &self because the fields it holds
are shared handles, not owned data.
Implementations§
Source§impl Form
impl Form
pub fn new() -> Self
pub fn field(self, f: FormField) -> Self
pub fn add_field(&mut self, f: FormField)
Sourcepub fn validate_all(&self) -> bool
pub fn validate_all(&self) -> bool
Run validate() on all fields. Returns true only if ALL pass.
Sourcepub fn errors(&self) -> Vec<FieldError>
pub fn errors(&self) -> Vec<FieldError>
Collect all errors from all fields.
Sourcepub fn field_named(&self, name: &str) -> Option<&FormField>
pub fn field_named(&self, name: &str) -> Option<&FormField>
Get a field by name.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
True if all fields pass validation (must call validate_all first,
or rely on a live-validating .field() binding — see TextInput/
TextArea’s Step 8 seam — to have kept this current).
pub fn is_empty(&self) -> bool
Sourcepub fn submit(&self, on_valid: impl FnOnce()) -> bool
pub fn submit(&self, on_valid: impl FnOnce()) -> bool
Validate every field; if all pass, run on_valid and return
true. The natural body of a submit button’s on_press (D116
Phase 28 Step 8) — Button::new("Submit").on_press(move || { form.submit(|| { ... }); }). Marks every field touched (via
validate_all’s own validate() calls reading the CURRENT
value — touched status itself comes from set(), unaffected
here), so an untouched-but-invalid field’s error becomes visible
immediately after a failed submit attempt, not just after the
user happens to edit it.