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 b40cb92a82..d0657ba083 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 @@ -1,6 +1,6 @@ /** * - * Copyright 2020 Florian Schmaus + * Copyright 2020-2024 Florian Schmaus * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,6 +55,7 @@ public FillableForm(DataForm dataForm) { } Set requiredFields = new HashSet<>(); + List requiredFieldsWithDefaultValue = new ArrayList<>(); for (FormField formField : dataForm.getFields()) { if (formField.isRequired()) { String fieldName = formField.getFieldName(); @@ -62,13 +63,17 @@ public FillableForm(DataForm dataForm) { if (formField.hasValueSet()) { // This is a form field with a default value. - write(formField); + requiredFieldsWithDefaultValue.add(formField); } else { missingRequiredFields.add(fieldName); } } } this.requiredFields = Collections.unmodifiableSet(requiredFields); + + for (FormField field : requiredFieldsWithDefaultValue) { + write(field); + } } protected void writeListMulti(String fieldName, List values) {