Skip to content

Commit

Permalink
ContactForm: Fix saving and populating contact addresses
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Jun 12, 2024
1 parent 5da809e commit 2ae3713
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions library/Notifications/Web/Form/ContactForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 2ae3713

Please sign in to comment.