checkboxes group: values in db vis email

sfaeh 12 Apr, 2012
i am a newbie with chronoforms.
in the forum I've found no answer to my question.
hope someone can help me here. πŸ™‚

i have a form with "checkboxes group".
formdisplay (frontend), email and save to DB works fine.

sample checkboxes group-field:
{workshop}
01=Workshop 1
02=Workshop 2
03=Workshop 3

values in frontend-form:
Workshop 1
Workshop 2
Workshop 3

values in db:
01,02,03

values in email:
01,02,03

for further processing, it would be easier if the values in the email are the same like in the forntend-form and the values in the db are in a shortform (01,02,03...).
Is this possible?

kind regards
stefan
GreyHead 12 Apr, 2012
Hi stefan,

You can do this by adding some PHP to the email template (or in a Custom Code action before the Email action) to re-expand the results.
<?php
$workshop_array = array(
  '01' => 'Workshop 1',
  '02' => 'Workshop 2',
  '03' => 'Workshop 3'
);
$workshops_long = array();
foreach ( $form->data['workshops'] as $v ) {
  $workshops_long[] = $workshop_array[$v];
}
$form->data['workshops_long'] = implode(', ', $workshops_long);
?>
Then you can put {workshops_long} in your email template.

Bob
sfaeh 12 Apr, 2012
Hi Bob,
thank you for the quick reply.

after the modification (Custom Code action before the Email action and before Handle Arrays action), the email output looks like:
Workshop 1,Workshop 2,Workshop 3,

I modified the code to make a Linebreak <br> after each value.
$form->data['workshops_long'] = implode("<br>", $workshops_long);

now the email output looks like:
Workshop 1
Workshop 2
Workshop 3


<?php
$workshop_array = array(
  '01' => 'Workshop 1',
  '02' => 'Workshop 2',
  '03' => 'Workshop 3'
);
$workshops_long = array();
foreach ( $form->data['workshops'] as $v ) {
  $workshops_long[] = $workshop_array[$v];
}
$form->data['workshops_long'] = implode("<br>", $workshops_long);
?>


many thanks
from a happy userπŸ˜€
This topic is locked and no more replies can be posted.