Skip to content

Commit

Permalink
Merge pull request #2191 from department-of-veterans-affairs/fix/LEAF…
Browse files Browse the repository at this point in the history
…-4030/email-template-multi-select-option

LEAF-4030: Multi Select Options on Email Templates not formatted correctly
  • Loading branch information
Pelentan authored Oct 31, 2023
2 parents bc13f66 + f44f905 commit 42987fe
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions LEAF_Request_Portal/sources/FormWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -1508,9 +1508,13 @@ private function getFields(): array
}
break;
case (str_starts_with($format, "checkboxes") != false):
if(!empty($data) && is_array(unserialize($data))){
$data = $this->buildCheckboxes(unserialize($data));
}
break;
case (str_starts_with($format, "multiselect") != false):
if ($this->isJsonString($data) && is_array(json_decode($data))) {
$data = $this->buildMultiselect(json_decode($data));
if(!empty($data) && is_array(unserialize($data))){
$data = $this->buildMultiselect(unserialize($data));
}
break;
case (str_starts_with($format, "radio") != false):
Expand Down Expand Up @@ -1577,6 +1581,16 @@ private function buildGrid(array $data): string
}

private function buildMultiselect(array $data): string
{
// filter out non-selected selections
$data = array_filter($data, function($x) { return $x !== "no"; });
// comma separate to be readable in email
$formattedData = "- " . implode("\r\n- ", $data);

return $formattedData;
}

private function buildCheckboxes(array $data): string
{
// filter out non-selected selections
$data = array_filter($data, function($x) { return $x !== "no"; });
Expand Down

0 comments on commit 42987fe

Please sign in to comment.