diff --git a/CHANGELOG.md b/CHANGELOG.md index a3440fb..9349360 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,11 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- Added the `CPR / Navn validering` element to allowed recipient element names + [PR-43](https://github.com/itk-dev/os2forms_digital_post/pull/43) + ## [2.0.1] ## Changed diff --git a/src/Helper/WebformHelperSF1601.php b/src/Helper/WebformHelperSF1601.php index 09a5e6b..886868b 100644 --- a/src/Helper/WebformHelperSF1601.php +++ b/src/Helper/WebformHelperSF1601.php @@ -159,6 +159,17 @@ public function sendDigitalPost(WebformSubmissionInterface $submission, array $h } $recipientIdentifier = $submissionData[$recipientIdentifierKey] ?? NULL; + + // Fix if os2forms_person_lookup (cpr & name validation) element is used. + if (is_array($recipientIdentifier)) { + // Example: + // [ + // 'cpr_number' => 1234567890, + // 'name' => Eksempel Eksempelsen, + // ]. + $recipientIdentifier = $recipientIdentifier['cpr_number'] ?? NULL; + } + if (NULL === $recipientIdentifier) { $message = 'Recipient identifier element (key: @element_key) not found in submission'; $context = [ diff --git a/src/Plugin/WebformHandler/WebformHandlerSF1601.php b/src/Plugin/WebformHandler/WebformHandlerSF1601.php index 603edbc..db60d10 100644 --- a/src/Plugin/WebformHandler/WebformHandlerSF1601.php +++ b/src/Plugin/WebformHandler/WebformHandlerSF1601.php @@ -246,6 +246,7 @@ private function getRecipientElements(): array { 'os2forms_nemid_company_cvr', 'os2forms_nemid_company_cvr_fetch_data', 'os2forms_nemid_cpr', + 'os2forms_person_lookup', // @todo Remove these when we remove the elements. 'cpr_element', 'cpr_value_element',