Skip to content

Commit

Permalink
Merge pull request #575 from Flowdalic/fix-npe-in-fillableform
Browse files Browse the repository at this point in the history
[xdata] Fix NPE in FillableForm
  • Loading branch information
Fishbowler authored Jan 10, 2024
2 parents 282d63d + 643d85c commit b117d8c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -54,20 +54,25 @@ public FillableForm(DataForm dataForm) {
}

Set<String> requiredFields = new HashSet<>();
List<FormField> requiredFieldsWithDefaultValue = new ArrayList<>();
for (FormField formField : dataForm.getFields()) {
if (formField.isRequired()) {
String fieldName = formField.getFieldName();
requiredFields.add(fieldName);

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<? extends CharSequence> values) {
Expand Down

0 comments on commit b117d8c

Please sign in to comment.