closes #3745 Fixes Rewrite of Multi-Select Token in Search Kit #24393
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
The Rewrite option for editing a display in a saved Search Kit search had a bug so that the token would only return the first value of a multi-select (i.e. multiple values) field.
Replication steps are available on the lab.civicrm issue
Before
Before this fix, if a token was used on the Rewrite option for a multi-select custom field, the display would only return the first value .
After
With the fix, the Search Kit display returns all values of the multi-select field when a token is used via the Rewrite option.
Technical Details
The bug was rooted in the
replaceToken()
function.$index
had a default argument of 0 in the function's parameters and with the way that$replacement
was being set on line 738, the function was only returning the first index of an array. This fix replaces the default argument withNULL
and puts the assignment of$replacement
as it was originally written within anif
statement that accounts for an$index
that is notNULL
.Comments
A unit test is included as part of this PR.