Fixed hiding of validation message in DataForm component.

This commit is contained in:
2023-11-16 21:45:53 +01:00
parent 14de6a1614
commit aa2c71af77
2 changed files with 10 additions and 2 deletions
+1 -1
View File
@@ -31,7 +31,7 @@ pub fn data_form<T: 'static + server_fn::ServerFn<()> + Clone + ForValidation>(
}
}
action=action>
<ModalDialog opener=opener title=title>
<ModalDialog opener=opener title=title validator=validator>
<ModalBody>
<ServerErr result={upd_val} opener=opener/>
<ValidationErr validator=validator />
+9 -1
View File
@@ -1,5 +1,6 @@
use crate::locales::trl;
use leptos::*;
use crate::validator::Validator;
#[derive(Copy, Clone)]
pub struct DialogOpener {
@@ -65,6 +66,8 @@ impl DialogOpener {
pub fn ModalDialog(
opener: DialogOpener,
title: &'static str,
#[prop(optional)]
validator: Option<Validator>,
children: Children,
) -> impl IntoView {
view! {
@@ -80,7 +83,12 @@ pub fn ModalDialog(
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
on:click=move |_| opener.hide()/>
on:click=move |_| {
if let Some(v) = validator {
v.reset();
}
opener.hide();
}/>
</div>
{children()}
</div>