Fixed hiding of validation message in DataForm component.

main
Josef Rokos 1 year ago
parent 14de6a1614
commit aa2c71af77

@ -31,7 +31,7 @@ pub fn data_form<T: 'static + server_fn::ServerFn<()> + Clone + ForValidation>(
} }
} }
action=action> action=action>
<ModalDialog opener=opener title=title> <ModalDialog opener=opener title=title validator=validator>
<ModalBody> <ModalBody>
<ServerErr result={upd_val} opener=opener/> <ServerErr result={upd_val} opener=opener/>
<ValidationErr validator=validator /> <ValidationErr validator=validator />

@ -1,5 +1,6 @@
use crate::locales::trl; use crate::locales::trl;
use leptos::*; use leptos::*;
use crate::validator::Validator;
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct DialogOpener { pub struct DialogOpener {
@ -65,6 +66,8 @@ impl DialogOpener {
pub fn ModalDialog( pub fn ModalDialog(
opener: DialogOpener, opener: DialogOpener,
title: &'static str, title: &'static str,
#[prop(optional)]
validator: Option<Validator>,
children: Children, children: Children,
) -> impl IntoView { ) -> impl IntoView {
view! { view! {
@ -80,7 +83,12 @@ pub fn ModalDialog(
class="btn-close" class="btn-close"
data-bs-dismiss="modal" data-bs-dismiss="modal"
aria-label="Close" aria-label="Close"
on:click=move |_| opener.hide()/> on:click=move |_| {
if let Some(v) = validator {
v.reset();
}
opener.hide();
}/>
</div> </div>
{children()} {children()}
</div> </div>

Loading…
Cancel
Save