[pdm-devel] [PATCH yew-widget-toolkit 1/1] form context: add method to check dirtiness of single fields

Shannon Sterz s.sterz at proxmox.com
Wed Nov 26 14:51:12 CET 2025


this allows checking whether a specific field has been updated or not
instead of only checking for the whole form.

Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
---
 src/widget/form/context.rs | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/widget/form/context.rs b/src/widget/form/context.rs
index 85de6734..8bdf5789 100644
--- a/src/widget/form/context.rs
+++ b/src/widget/form/context.rs
@@ -690,6 +690,17 @@ impl FormContextState {
         self.version += 1;
     }

+    /// Check if the field identified by `name` has been changed.
+    ///
+    /// If the there is no field with `name`, `None` will be returned.
+    pub fn is_field_dirty(&self, name: impl IntoPropValue<AttrValue>) -> Option<bool> {
+        let name = name.into_prop_value();
+        self.fields
+            .iter()
+            .find(|(_key, f)| &f.name == &name)
+            .map(|(_key, f)| f.is_dirty())
+    }
+
     pub fn is_dirty(&self) -> bool {
         for (_name, group) in self.groups.clone().iter() {
             if group.radio_count > 0 && group.default != group.value {
--
2.47.3





More information about the pdm-devel mailing list