Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from this requirement in BKDK-550:
https://os2web.atlassian.net/browse/BKDK-550?focusedCommentId=64745

The address field needed to have a hint that it's protected/beskyttet

I see that this key is most likely custom one: #info_message i also don't see any theme using it. For me, it's same to delete this line

If that answers the questions, please remove todo comment from the code 🙂

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stankut, do you suggest removing

        $element['#info_message'] = 'adresse beskyttelse';

(along with the todo comment)?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, that was my idea. Please do that while you're on it, i see no effect of this line anymore

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two lines removed in a24177e, @stankut. Please re-review.

$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