From c8186eea13a0eba903d5fe73c38edf229ed7bf76 Mon Sep 17 00:00:00 2001 From: Ben Wishovich Date: Tue, 16 Apr 2024 14:52:51 -0700 Subject: [PATCH] Add id to ActionForm and MultiActionForm (#2535) --- router/src/components/form.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/router/src/components/form.rs b/router/src/components/form.rs index 2601b9359..a58d5fe88 100644 --- a/router/src/components/form.rs +++ b/router/src/components/form.rs @@ -444,9 +444,13 @@ pub fn ActionForm( ServFn, Result>, >, + /// Sets the `id` attribute on the underlying `
` tag + #[prop(optional, into)] + id: Option, /// Sets the `class` attribute on the underlying `` tag, making it easier to style. #[prop(optional, into)] class: Option, + /// A [`NodeRef`] in which the `` element should be stored. #[prop(optional)] node_ref: Option>, @@ -481,6 +485,7 @@ where let value = action.value(); let class = class.map(|bx| bx.into_attribute_boxed()); + let id = id.map(|bx| bx.into_attribute_boxed()); let on_submit = { move |ev: SubmitEvent| { @@ -524,6 +529,7 @@ where let mut action_form = form() .attr("action", action_url) .attr("method", "post") + .attr("id", id) .attr("class", class) .on(ev::submit, on_submit) .child(children()); @@ -549,6 +555,9 @@ pub fn MultiActionForm( /// by default using [create_server_action](leptos_server::create_server_action) or added /// manually using [leptos_server::Action::using_server_fn]. action: MultiAction>, + /// Sets the `id` attribute on the underlying `` tag + #[prop(optional, into)] + id: Option, /// Sets the `class` attribute on the underlying `` tag, making it easier to style. #[prop(optional, into)] class: Option, @@ -610,9 +619,12 @@ where }; let class = class.map(|bx| bx.into_attribute_boxed()); + + let id = id.map(|bx| bx.into_attribute_boxed()); let mut action_form = form() .attr("action", action_url) .attr("method", "post") + .attr("id", id) .attr("class", class) .on(ev::submit, on_submit) .child(children());