List view display of array

Status
Not open for further replies.

bobede

Member
I've hunted around but can't really seem to find what I'm after.

I have a form with a few different checkbox type questions. Something like this
Question 1 - _A _B _C
Question 2 - _1 _2 _3 _4
Question 3 - _d _e _f

Then I have a calc element with a calculation that looks like this
return '{mydb___question_1}' . '{mydb___question_2}' . '{mydb___question_3}';
and this works to return an array of the answers selected in the 3 questions.

What I'm wondering about is the formatting of the display of the returned result. As it is it looks something like this:
["B"]["1","4"][""]
Is there a way to change my calc code so what gets returned would look more like this?
B, 1, 4

Or do I need to create a custom list template to format the array in this fashion. If so is there an example to work from like that wonderful video Rob did on custom templating a details view?

Thanks
 
Figured it out. I was able to use code similar to this.

Code:
$mdarray = ('{mydb___question_1}' . '{mydb___question_2}' . 'mydb___question_3}');
return  str_replace( array('[',']','"',',') , ' '  , $mdarray );

This effectively removes the square brackets, the quotes and the commas. I opted to remove the commas as the end result was easier to read if Q1 or Q2 had no data.

I hope this helps someone else.
 
This code may fail.
Missing '{'.
$mdarray = ('{mydb___question_1}' . '{mydb___question_2}' . '{mydb___question_3}');
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top