Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa

## [Unreleased]

- Avoid double-saving submissions when handling name and address protection.

## [4.1.0] 2025-06-03

- [PR-176](https://github.com/OS2Forms/os2forms/pull/176)
Expand Down
1 change: 0 additions & 1 deletion modules/os2forms_nemid/os2forms_nemid.module
Original file line number Diff line number Diff line change
Expand Up @@ -469,5 +469,4 @@ function os2forms_nemid_submission_set_address_protected(array $form, FormStateI
$data = $webformSubmission->getData();
$data['os2forms_nemid_elements_nemid_address_protected'] = TRUE;
$webformSubmission->setData($data);
$webformSubmission->save();
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,21 @@ public function alterForm(array &$element, array &$form, FormStateInterface $for
// Only manipulate element on submission create form.
if (!$webformSubmission->isCompleted()) {
if ($cprLookupResult && $cprLookupResult->isNameAddressProtected()) {
// @todo What is this used for?
$element['#info_message'] = 'adresse beskyttelse';
NestedArray::setValue($form['elements'], $element['#webform_parents'], $element);
$form['actions']['submit']['#submit'][] = 'os2forms_nemid_submission_set_address_protected';

// It is important the 'os2forms_nemid_submission_set_address_protected'
// submit action is executed before the 'save' action. Otherwise,
// submissions are both created and completed, resulting in unexpected
// behavior, e.g., handlers being run twice.
if (isset($form['actions']['submit']['#submit']) && is_array($form['actions']['submit']['#submit'])) {
array_unshift($form['actions']['submit']['#submit'], 'os2forms_nemid_submission_set_address_protected');
}
else {
$form['actions']['submit']['#submit'][] = 'os2forms_nemid_submission_set_address_protected';
}

}
}
else {
Expand Down