From 2ae37133dcfc38c192c99fd2c8b286be0614c929 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Tue, 4 Jun 2024 13:25:34 +0200 Subject: [PATCH] ContactForm: Fix saving and populating contact addresses --- library/Notifications/Web/Form/ContactForm.php | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/library/Notifications/Web/Form/ContactForm.php b/library/Notifications/Web/Form/ContactForm.php index fe4ba79f..17c7f0f4 100644 --- a/library/Notifications/Web/Form/ContactForm.php +++ b/library/Notifications/Web/Form/ContactForm.php @@ -172,20 +172,7 @@ public function populate($values) } foreach ($values->contact_address as $contactInfo) { - if (! isset($formValues['contact_address'])) { - $formValues['contact_address'] = [ - 'email' => null, - 'rocketchat' => null - ]; - } - - if ($contactInfo->type === 'email') { - $formValues['contact_address']['email' ] = $contactInfo->address; - } - - if ($contactInfo->type === 'rocketchat') { - $formValues['contact_address']['rocketchat'] = $contactInfo->address; - } + $formValues['contact_address'][$contactInfo->type] = $contactInfo->address; } $values = $formValues; @@ -222,8 +209,7 @@ public function addOrUpdateContact() } } - $addr = ! empty($addressFromDb) ? $addressFromDb : $addressFromForm; - foreach ($addr as $type => $value) { + foreach ($addressFromForm as $type => $value) { $this->insertOrUpdateAddress($type, $addressFromForm, $addressFromDb); }