| Crates.io | form_fields_macro |
| lib.rs | form_fields_macro |
| version | 0.1.7 |
| created_at | 2025-06-15 18:45:29.944704+00 |
| updated_at | 2025-10-05 22:24:36.105581+00 |
| description | Helper crate for working with HTML forms. |
| homepage | |
| repository | https://github.com/HookedBehemoth/axum-form-fields |
| max_upload_size | |
| id | 1713535 |
| size | 93,103 |
Helper crate for working with HTML forms in axum.
Simplifies the parsing and validating user input for creating new and editing existing data in your application.
Learn about all the possible macro attributes here.
In The Examples folder folder, you can find a few basic examples.
Derive from "FromForm" on a struct with the data you allow the user to submit.
#[derive(Debug, FromForm)]
struct Test {
#[text_field(display_name = "Required Text", max_length = 50)]
text: String,
}
This will generate a Form-Spec, which can be retrieved in your axum-handlers.
async fn simple(method: Method, FromForm(mut form): FromForm<Test>) -> Response<Body> {
if method == Method::POST {
let inner = form.inner().unwrap();
println!("Form submitted: text: {}", inner.text);
}
html! {
h1 { "Simple Form Example" }
form method="POST" {
(form.text)
input type="submit";
}
}
.into_response()
}
Currently, only maud is supported, but all data is exposed so rendering the inputs in any other markup generator or even altering the format is possible.