| Crates.io | leptos_form |
| lib.rs | leptos_form |
| version | 0.2.0-rc1 |
| created_at | 2023-11-01 01:04:51.004254+00 |
| updated_at | 2024-02-05 21:11:03.832236+00 |
| description | Derive forms from structs. |
| homepage | |
| repository | https://github.com/tlowerison/leptos_form |
| max_upload_size | |
| id | 1020532 |
| size | 49,792 |
This crate offers the following features, all of which are not activated by default:
bigdecimal: Provides impls for BigDecimalcache-local-storage: Provides support for writing intermediate form data to/from local storage.cache-serde_json: Provides support for (de)serializing form state as JSON.chrono: Provides impls for DateTime, NaiveDate, NaiveDateTimenum-bigint: Provides impls for BigInt and BigUintuuid: Provides impls for Uuidmod my_crate {
use leptos::*;
use leptos_form::prelude::*;
use serde::*;
#[derive(Clone, Debug, Default, Deserialize, Form, Serialize)]
#[form(
component(
action = create_my_data(my_data),
on_success = |DbMyData { id, .. }, _| view!(<div>{format!("Created {id}")}</div>),
reset_on_success,
),
label(wrap(class = "my-class", rename_all = "Title Case")),
)]
pub struct MyData {
pub my_name: String,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct DbMyData {
pub id: i32,
pub name: String,
}
#[component]
pub fn MyComponent() -> impl IntoView {
view! {
<MyData
initial={MyData::default()}
top=|| view!(<input type="button" value="Submit" />)
/>
}
}
#[server]
async fn create_my_data(my_data: MyData) -> Result<DbMyData, ServerFnError> {
todo!()
}
}