Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ 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.
- [PR-191](https://github.com/OS2Forms/os2forms/pull/191)
Re-throws exception to ensure failed status during Maestro notification job.
- [PR-202](https://github.com/OS2Forms/os2forms/pull/202)
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();
}
14 changes: 12 additions & 2 deletions modules/os2forms_nemid/src/Plugin/WebformElement/NemidAddress.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,19 @@ public function alterForm(array &$element, array &$form, FormStateInterface $for
// Only manipulate element on submission create form.
if (!$webformSubmission->isCompleted()) {
if ($cprLookupResult && $cprLookupResult->isNameAddressProtected()) {
$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
Loading