Form

The Form component wires HTML forms to #[submit] handlers with progressive enhancement.

Basic form

#[submit]
async fn contact(form: ContactForm, _req: &FlowRequest)
    -> Result<ContactResult, SubmitError>
{
    if form.email.is_empty() {
        return Err(SubmitError::new("Fix errors")
            .field("email", "Required"));
    }
    Ok(ContactResult { ok: true })
}

view! {
    <Form submit={contact}>
        <input name="email" type="email" />
        <input name="name" type="text" />
        <button type="submit">"Send"</button>
    </Form>
}

Progressive enhancement

Form renders method=\"POST\" and action=\"/_resuma/submit/:name\". Without JavaScript, the browser submits normally. With the runtime loaded, submit is intercepted for SPA-style updates.

Client-side feedback

When the runtime intercepts submit, responses include ok, value, error, and field_errors. Use js! for optimistic UI updates after submit.

See also

Submit handler details on Actions (submits).