8 releases
Uses new Rust 2024
| 0.1.7 | Oct 5, 2025 |
|---|---|
| 0.1.6 | Oct 5, 2025 |
| 0.1.5 | Aug 1, 2025 |
| 0.1.4 | Jun 20, 2025 |
#2580 in Procedural macros
433 downloads per month
Used in form_fields
35KB
744 lines
Form Fields
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.
Documentation
Learn about all the possible macro attributes here.
Examples
In The Examples folder folder, you can find a few basic examples.
Basic usage
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.
Goals for stable release
- documentation
- better naming (help needed)
- descriptor
- feature segregation
- multer & form_urlencoded
- axum
- renderers
- chrono
- file handling
- loaded fully
- async user handled
- HTML renderers
- maud
- clean up macro code
- clearer error handling
Dependencies
~4.5MB
~88K SLoC