Delimiter for Multi-Select Repeater Field missing?

I have a multi-select repeater field with a list of resources.

The list is showing up as expected, but on the frontend side I get this:

194187183119920681190

what I would expect is something like this:

194,187,183,119,920,681,190

(the ids are correct).

I can neither find a system setting nor an options inside the multi-select cb modal.

core/components/contentblocks/elements/inputs/multiselectinput.class.php, line 20 only concatenates the output.

public function process(cbField $field, array $data = []): string
{
$tpl = $field->get(‘template’);

$output = '';
foreach ($data as $k => $datum) {
    if ($k === 'value') {
        foreach ($datum as $value) {
            $output .= $this->contentBlocks->parse($tpl, ['value' => $value]);
        }
    }
}
return $output;

}

I don’t think this is how this function should work.

I guess it should be more like this:

public function process(cbField $field, array $data = []): string
{
$tpl = $field->get(‘template’);

$output = array();
foreach ($data as $k => $datum) {
    if ($k === 'value') {
        foreach ($datum as $value) {
            $output[] = $this->contentBlocks->parse($tpl, ['value' => $value]);
        }
    }
}

$delimiter = ','; // should be a system setting
$output = implode($delimiter,$output);

return $output;

}

This solves my problem, but I’m afraid that this might break something.

What are your thoughts?

Hi @pepebe

I hope you’re enjoying the holidays! :slight_smile:

I agree, a delimiter property on the multi-select input type form would indeed be a useful feature, especially if you’re using resource ids.
I’ll look at getting this added hopefully to the next release.

At a glance, I don’t see a reason why your code would break anything else… just remember that it’ll get overwritten the next time you update.
It might be safer for now to add a comma after [[+value]] on the multi-select template property.

Actually, now I think about it, also giving the multi-select field a wrapper template for when it’s not used in a repeater could be handy too. I’m adding this and your delimiter request to our internal tracker.

1 Like

Hi @pepebe,

Just to let you know, version 1.12.0-pl has just been released with a separator/delimiter property field for the multi-select input and setting. :slight_smile:

1 Like

Thanks,
I’ll have a look

Happy new year

1 Like