From 090858f467c8211b97dc487266a822f5731a252f Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 1 Apr 2021 12:55:28 +0200 Subject: [PATCH] [xdata] Automatically fill required fields with a default value --- .../org/jivesoftware/smackx/xdata/form/FillableForm.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java index 22f257a4e..b40cb92a8 100644 --- a/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java +++ b/smack-extensions/src/main/java/org/jivesoftware/smackx/xdata/form/FillableForm.java @@ -59,7 +59,13 @@ public class FillableForm extends FilledForm { if (formField.isRequired()) { String fieldName = formField.getFieldName(); requiredFields.add(fieldName); - missingRequiredFields.add(fieldName); + + if (formField.hasValueSet()) { + // This is a form field with a default value. + write(formField); + } else { + missingRequiredFields.add(fieldName); + } } } this.requiredFields = Collections.unmodifiableSet(requiredFields);