Skip to content

Commit

Permalink
ContactGroupForm: Make members field optional
Browse files Browse the repository at this point in the history
  • Loading branch information
sukhwinder33445 committed Jun 11, 2024
1 parent ac6c1e7 commit 0cc4e12
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions application/forms/ContactGroupForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ protected function assemble(): void
$termInput = (new TermInput(
'group_members',
[
'label' => $this->translate('Members'),
'required' => true
'label' => $this->translate('Members')
]
))
->setVerticalTermDirection()
Expand Down Expand Up @@ -224,8 +223,15 @@ public function editGroup(): bool
$isUpdated = true;
}

$storedContacts = explode(',', $storedValues['group_members']);
$newContacts = explode(',', $values['group_members']);
$storedContacts = [];
if (! empty($storedValues['group_members'])) {
$storedContacts = explode(',', $storedValues['group_members']);
}

$newContacts = [];
if (! empty($values['group_members'])) {
$newContacts = explode(',', $values['group_members']);
}

$toDelete = array_diff($storedContacts, $newContacts);
$toAdd = array_diff($newContacts, $storedContacts);
Expand Down

0 comments on commit 0cc4e12

Please sign in to comment.