pub struct ActionFormProps<ServFn, OutputProtocol>where
ServFn: DeserializeOwned + ServerFn<Protocol = Http<PostUrl, OutputProtocol>> + Clone + Send + Sync + 'static,
<<<ServFn as ServerFn>::Client as Client<<ServFn as ServerFn>::Error>>::Request as ClientReq<<ServFn as ServerFn>::Error>>::FormData: From<FormData>,
<ServFn as ServerFn>::Output: Send + Sync + 'static,
<ServFn as ServerFn>::Error: Send + Sync + 'static,
<ServFn as ServerFn>::Client: Client<<ServFn as ServerFn>::Error>,{
pub action: ServerAction<ServFn>,
pub node_ref: Option<NodeRef<Form>>,
pub children: Box<dyn FnOnce() -> AnyView + Send>,
}Expand description
Props for the ActionForm component.
Automatically turns a server Action into an HTML
form
progressively enhanced to use client-side routing.
§Encoding
Note: <ActionForm/> only works with server functions that use the
default Url encoding. This is to ensure that <ActionForm/> works correctly
both before and after WASM has loaded.
§Complex Inputs
Server function arguments that are structs with nested serializable fields
should make use of indexing notation of serde_qs.
use leptos::form::ActionForm;
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
struct HeftyData {
first_name: String,
last_name: String,
}
#[component]
fn ComplexInput() -> impl IntoView {
let submit = ServerAction::<VeryImportantFn>::new();
view! {
<ActionForm action=submit>
<input type="text" name="hefty_arg[first_name]" value="leptos"/>
<input
type="text"
name="hefty_arg[last_name]"
value="closures-everywhere"
/>
<input type="submit"/>
</ActionForm>
}
}
#[server]
async fn very_important_fn(
hefty_arg: HeftyData,
) -> Result<(), ServerFnError> {
assert_eq!(hefty_arg.first_name.as_str(), "leptos");
assert_eq!(hefty_arg.last_name.as_str(), "closures-everywhere");
Ok(())
}§Required Props
- action:
ServerAction<ServFn>- The action from which to build the form.
- children:
Children- Component children; should include the HTML of the form elements.
§Optional Props
- node_ref:
NodeRef<Form>- A
NodeRefin which the<form>element should be stored.
- A
Fields§
§action: ServerAction<ServFn>The action from which to build the form.
node_ref: Option<NodeRef<Form>>A NodeRef in which the <form> element should be stored.
children: Box<dyn FnOnce() -> AnyView + Send>Component children; should include the HTML of the form elements.
Implementations§
Source§impl<ServFn, OutputProtocol> ActionFormProps<ServFn, OutputProtocol>where
ServFn: DeserializeOwned + ServerFn<Protocol = Http<PostUrl, OutputProtocol>> + Clone + Send + Sync + 'static,
<<<ServFn as ServerFn>::Client as Client<<ServFn as ServerFn>::Error>>::Request as ClientReq<<ServFn as ServerFn>::Error>>::FormData: From<FormData>,
<ServFn as ServerFn>::Output: Send + Sync + 'static,
<ServFn as ServerFn>::Error: Send + Sync + 'static,
<ServFn as ServerFn>::Client: Client<<ServFn as ServerFn>::Error>,
impl<ServFn, OutputProtocol> ActionFormProps<ServFn, OutputProtocol>where
ServFn: DeserializeOwned + ServerFn<Protocol = Http<PostUrl, OutputProtocol>> + Clone + Send + Sync + 'static,
<<<ServFn as ServerFn>::Client as Client<<ServFn as ServerFn>::Error>>::Request as ClientReq<<ServFn as ServerFn>::Error>>::FormData: From<FormData>,
<ServFn as ServerFn>::Output: Send + Sync + 'static,
<ServFn as ServerFn>::Error: Send + Sync + 'static,
<ServFn as ServerFn>::Client: Client<<ServFn as ServerFn>::Error>,
Trait Implementations§
Source§impl<ServFn, OutputProtocol> Props for ActionFormProps<ServFn, OutputProtocol>where
ServFn: DeserializeOwned + ServerFn<Protocol = Http<PostUrl, OutputProtocol>> + Clone + Send + Sync + 'static,
<<<ServFn as ServerFn>::Client as Client<<ServFn as ServerFn>::Error>>::Request as ClientReq<<ServFn as ServerFn>::Error>>::FormData: From<FormData>,
<ServFn as ServerFn>::Output: Send + Sync + 'static,
<ServFn as ServerFn>::Error: Send + Sync + 'static,
<ServFn as ServerFn>::Client: Client<<ServFn as ServerFn>::Error>,
impl<ServFn, OutputProtocol> Props for ActionFormProps<ServFn, OutputProtocol>where
ServFn: DeserializeOwned + ServerFn<Protocol = Http<PostUrl, OutputProtocol>> + Clone + Send + Sync + 'static,
<<<ServFn as ServerFn>::Client as Client<<ServFn as ServerFn>::Error>>::Request as ClientReq<<ServFn as ServerFn>::Error>>::FormData: From<FormData>,
<ServFn as ServerFn>::Output: Send + Sync + 'static,
<ServFn as ServerFn>::Error: Send + Sync + 'static,
<ServFn as ServerFn>::Client: Client<<ServFn as ServerFn>::Error>,
Auto Trait Implementations§
impl<ServFn, OutputProtocol> Freeze for ActionFormProps<ServFn, OutputProtocol>
impl<ServFn, OutputProtocol> !RefUnwindSafe for ActionFormProps<ServFn, OutputProtocol>
impl<ServFn, OutputProtocol> Send for ActionFormProps<ServFn, OutputProtocol>
impl<ServFn, OutputProtocol> !Sync for ActionFormProps<ServFn, OutputProtocol>
impl<ServFn, OutputProtocol> Unpin for ActionFormProps<ServFn, OutputProtocol>
impl<ServFn, OutputProtocol> !UnwindSafe for ActionFormProps<ServFn, OutputProtocol>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> SerializableKey for T
impl<T> SerializableKey for T
Source§impl<T> StorageAccess<T> for T
impl<T> StorageAccess<T> for T
Source§fn as_borrowed(&self) -> &T
fn as_borrowed(&self) -> &T
Borrows the value.
Source§fn into_taken(self) -> T
fn into_taken(self) -> T
Takes the value.