* [yew-devel] [PATCH yew-widget-toolkit] form: fix dirty check when validator normalizes field values
@ 2025-11-10 16:18 Hannes Laimer
0 siblings, 0 replies; only message in thread
From: Hannes Laimer @ 2025-11-10 16:18 UTC (permalink / raw)
To: yew-devel
Having a default value for a field that was not be present in the initial
data led to the form being marked as dirty immediatly.
Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
src/widget/form/context.rs | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/src/widget/form/context.rs b/src/widget/form/context.rs
index e0cad70..1398847 100644
--- a/src/widget/form/context.rs
+++ b/src/widget/form/context.rs
@@ -461,6 +461,11 @@ impl FormContextState {
if !radio_group {
field.apply_value(value);
+ // update default to match the validated result, so dirty checking works correctly
+ // when the validator normalizes the value
+ if let Ok(submit_value) = &field.result {
+ field.default = submit_value.clone();
+ }
}
let slab_key;
--
2.47.3
_______________________________________________
yew-devel mailing list
yew-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/yew-devel
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-10 16:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-10 16:18 [yew-devel] [PATCH yew-widget-toolkit] form: fix dirty check when validator normalizes field values Hannes Laimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox