Skip to content

Commit

Permalink
Fix non-empty label preference in backed lead list
Browse files Browse the repository at this point in the history
  • Loading branch information
rabauss committed Nov 26, 2024
1 parent 1aa3063 commit 0a25531
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/EventListener/DataContainer/LeadLabelListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,13 @@ public function __invoke(array $row, string $label): string

$records = $this->connection->fetchAllAssociative('SELECT name, value, label FROM tl_lead_data WHERE pid=?', [$row['id']]);

foreach ($records as $record) {
foreach ($records as $record) {
$label = StringUtil::deserialize($record['label']);
$value = (is_array($label) && array_filter($label)) || (!is_array($label) && !empty($label)) ? $label : StringUtil::deserialize($record['value']);
if ($this->stringParser) {
$this->stringParser->flatten(StringUtil::deserialize($record['label'] ?: $record['value']), $record['name'], $tokens);
$this->stringParser->flatten($value, $record['name'], $tokens);
} else {
\Haste\Util\StringUtil::flatten(StringUtil::deserialize($record['label'] ?: $record['value']), $record['name'], $tokens);
\Haste\Util\StringUtil::flatten($value, $record['name'], $tokens);
}
}

Expand Down

0 comments on commit 0a25531

Please sign in to comment.