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 c14990a9a1..332c7fc3ff 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. @@ -54,6 +54,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(); @@ -61,13 +62,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) {