Forums

CF6: display values of checkboxes retrieved from database in repeater area

Erik66 08 Jan, 2019
I have CF6 form that displays values retrieved from a database table. The values are shown in a repeater area. One of th ecolumns contains data stored fomr a list of checkboxes. The values in the database are stored as

["value_1","value_2","value_3",....]

When retrieved, they are displayed exactly as that. I would however like them to show up as a text string in the form

"value_1, value_2, value_3,..."

I tried fiddling around with the {data.join:values} and {data.join[,]:values} methods but I can not find the correct way of combining this with the code used for retrieving the values in the repeater area. The code used to retrieve the contents for the field in the repetaer area is

{var:area_repeater42.row.Model.column_name}

So what is the correct code to use in order to have the desired display of this content?

Any help = greatly appreciated!

Erik
healyhatman 08 Jan, 2019
{var.join[, ]:area_repeater42.row.Model.column_name}
Erik66 08 Jan, 2019
Thank you healyhatman, I tried this but the output is still in the format ["value_1","value_2","value_3",....].
healyhatman 08 Jan, 2019
Answer
1 Likes
OK I get it now. You will need to do it in PHP since it's a json_encoded string and you want it formatted a certain way. {var.jsonde} won't work because reasons.

So I would use a Custom HTML block and you're going to need
<?php
echo implode(", ", json_decode($this->get("area_repeater42.row.Model.column_name")));
?>
DO NOT COPY PASTE THIS, type it manually. The forums adds hidden characters.
Erik66 08 Jan, 2019
Thank you healyhatman! That sulutions works flawlessly.
This topic is locked and no more replies can be posted.