From 956c653e2897cb802158550c9c476192bd3a4e90 Mon Sep 17 00:00:00 2001 From: Lucas Vas Date: Wed, 4 Feb 2026 22:01:44 -0500 Subject: [PATCH] fix: allow uniquely named lists to work with multientry component --- src/common/form_schema.rs | 10 +++++++++- src/components/lists/multi/checkbox.rs | 6 +++++- src/components/lists/single/radio.rs | 3 ++- src/components/multi_entry.rs | 22 +++++++++++++++------- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/common/form_schema.rs b/src/common/form_schema.rs index 4825f60..f7bca1e 100644 --- a/src/common/form_schema.rs +++ b/src/common/form_schema.rs @@ -26,7 +26,14 @@ pub enum InputType { } impl InputType { - pub fn into_view(self, data_map: RwSignal>) -> impl IntoView { + /// Converts an `InputType` into an `impl IntoView`. A name must be specified in the case that + /// the component is a checkbox/radio list, which requires a unique name to function properly. + /// Many times, the name will be the same as the data member. + pub fn into_view( + self, + data_map: RwSignal>, + name: String, + ) -> impl IntoView { view! { {match self { InputType::Text(member, label, placeholder, required) => @@ -56,6 +63,7 @@ impl InputType { view! { , /// The data member that this list should edit/display from the `data_map`. #[prop(into)] data_member: Signal, /// A [`Signal`] allowing access to a data store. @@ -160,7 +164,7 @@ pub fn CheckboxList( on_change=on_change // The actual selected values are tracked by this element, not by the checkboxes themselves. value=item - name=data_member + name=move || format!("{}_{}", name.get(), data_member.get()) disabled=disabled /> } diff --git a/src/components/lists/single/radio.rs b/src/components/lists/single/radio.rs index e5a61b7..e28c0f0 100644 --- a/src/components/lists/single/radio.rs +++ b/src/components/lists/single/radio.rs @@ -151,6 +151,7 @@ pub fn RadioList( #[prop(optional, into)] label: String, #[prop(optional, into)] required: Signal, #[prop(optional, into)] other_prompt: Signal, + #[prop(optional, into)] name: Signal ) -> impl IntoView { //#region Value Logic @@ -262,7 +263,7 @@ pub fn RadioList( on_change=on_change // The actual selected values are tracked by this element, not by the checkboxes themselves. value=item - name=data_member + name=move || format!("{}_{}", name.get(), data_member.get()) disabled=disabled /> } diff --git a/src/components/multi_entry.rs b/src/components/multi_entry.rs index 4bebba6..4a2ffec 100644 --- a/src/components/multi_entry.rs +++ b/src/components/multi_entry.rs @@ -125,13 +125,17 @@ pub fn MultiEntry( > } + view! { } } /> @@ -181,19 +185,23 @@ fn Entry( /// The data map that contains all information. Data is found within this map using the `member` /// props. This map should be unique to this entry; in other words, it should be contained and /// passed down from within the entry list in the parent `MultiEntry` component. - #[prop()] - data_map: RwSignal>, + #[prop()] data_map: RwSignal>, /// The schema of this entry. Should contain all information about what inputs to use and what /// data members those inputs modify. - #[prop(into)] - schema: Signal>, + #[prop(into)] schema: Signal>, + /// The unique ID for this entry. + #[prop(into)] id: Signal, ) -> impl IntoView { view! {
{schema .get() .iter() - .map(|input_type| { input_type.clone().into_view(data_map.clone()) }) + .map(|input_type| + input_type + .clone() + .into_view(data_map.clone(), id.get()) + ) .collect_view()}
}