[yew-devel] [PATCH yew-widget-toolkit] form: fix dirty check when validator normalizes field values

Hannes Laimer h.laimer at proxmox.com
Mon Nov 10 17:18:30 CET 2025


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 at 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





More information about the yew-devel mailing list