diff --git a/router/src/components/form.rs b/router/src/components/form.rs index 583070357..10a7bb4b1 100644 --- a/router/src/components/form.rs +++ b/router/src/components/form.rs @@ -124,42 +124,32 @@ where } } -/// Properties that can be passed to the [ActionForm] component, which -/// automatically turns a server [Action](leptos_server::Action) into an HTML -/// [`form`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) -/// progressively enhanced to use client-side routing. -#[derive(TypedBuilder)] -pub struct ActionFormProps -where - I: 'static, - O: 'static, -{ - /// The action from which to build the form. This should include a URL, which can be generated - /// by default using [create_server_action](leptos_server::create_server_action) or added - /// manually using [leptos_server::Action::using_server_fn]. - pub action: Action>, - /// Component children; should include the HTML of the form elements. - pub children: Box Fragment>, -} - /// Automatically turns a server [Action](leptos_server::Action) into an HTML /// [`form`](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/form) /// progressively enhanced to use client-side routing. -#[allow(non_snake_case)] -pub fn ActionForm(cx: Scope, props: ActionFormProps) -> impl IntoView +#[component] +pub fn ActionForm( + cx: Scope, + /// The action from which to build the form. This should include a URL, which can be generated + /// by default using [create_server_action](leptos_server::create_server_action) or added + /// manually using [leptos_server::Action::using_server_fn]. + action: Action>, + /// Component children; should include the HTML of the form elements. + children: Box Fragment>, +) -> impl IntoView where I: Clone + ServerFn + 'static, O: Clone + Serializable + 'static, { - let action = if let Some(url) = props.action.url() { + let action_url = if let Some(url) = action.url() { url } else { debug_warn!(" action needs a URL. Either use create_server_action() or Action::using_server_fn()."); "" }.to_string(); - let version = props.action.version; - let value = props.action.value; - let input = props.action.input; + let version = action.version; + let value = action.value; + let input = action.input; let on_form_data = Rc::new(move |form_data: &web_sys::FormData| { let data = action_input_from_form_data(form_data); @@ -198,12 +188,12 @@ where Form( cx, FormProps::builder() - .action(action) + .action(action_url) .version(version) .on_form_data(on_form_data) .on_response(on_response) .method("post") - .children(props.children) + .children(children) .build(), ) }