Solspace’s Freeform will handle a checkbox array quite well, but for the email output it’ll put each value on its own line. I’d like to have all the values on a single line in comma separate format. Anyone pulled this off?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
October 09, 2007 3:47pm
Subscribe [3]#1 / Oct 09, 2007 3:47pm
Solspace’s Freeform will handle a checkbox array quite well, but for the email output it’ll put each value on its own line. I’d like to have all the values on a single line in comma separate format. Anyone pulled this off?
#2 / Oct 10, 2007 3:27am
Hi Todd
I really don’t know how to do it with EE tags, but if you want to use PHP code, you can use the implode() function.
It has two parameters, the first is the “glue string”, it’s the character/s that will be between each element, and the second parameter is the array.
If you have the array $colors with values “Green”, “Blue” and “Orange”:
implode(’,’ , $colors) will return “Green,Blue,Orange”.
But remember the first parameter is not limited to one character, in can be a string, so if you want spaces:
implode(’, ’ , $colors) will return “Green, Blue, Orange”.
Is that what you need?
#3 / Oct 10, 2007 8:39am
I found the implode function in the module and changed it from a line break (\n) to a comma separated format:
// If the field is a multi-select field, then handle it as such.
if ( is_array( $val ) )
{
$val = implode( ", ", $val );
$data[$key] = $REGX->xss_clean($val);
}
else
{
$data[$key] = $REGX->xss_clean($val);
}
}Works well.