Email template - only send records from visible groups

Hi,

I have a form with rather many groups. I would like the email which is sent with the email plugin only to send elements from the visible groups.

The show/hide of the groups is controlled by a checkbox field with the element name:
?table___trigger?. The values of table___trigger is ?Group1?, ?Group2?.... ?Group20?.

The names of the groups are ?Group1?, ?Group2?... ?Group20?. ?Group1? is hidden if ?table___trigger? is not ?Group1?, ?Group2? is hidden if ?table___trigger? is not ?Group2? and so on.

I understand I need a php template but my php knowledge is unfortunelately very limited. I appreciate any help. Thank you.

Regards, Jon


(Sorry if you already have answered this before but I've tried to search without any luck)
 
hi - could you point me at the form, it would help me give you a more accurate answer.
thanks
Rob
 
Thank you.

Link: http://lokaldugnad.fordelsgruppen.no/2-uncategorised/7-forsikring-veldedig-organisasjon

Username and password is provided under "My sites". You also have superuser access backend.

I have made some minor changes on the form and the show/hide of he groups is now controlled by three elements which you can see on the second page, "Valg av forsikringer", of the form. The name of the elements are: forsikringer___Husoghjem, forsikringer___Person and forsikringer___Motorkjoretoy

Backend the name of the form is "Forsikringer". Let me know if there is anything I need to clearify.
 
Please feel free to bump if I've not replied in a couple of days, I tend to review (and attempt to answer) threads from the previous 3 days so sometimes things do drop off my radar when its hectic here.
So to get this to work, you are going to need to create a php template (located in plugins/fabrik_form/plugin/email/tmpl) which you will then need to select as the php template in the email plugin.
It's content should look something along the lines of this (obviously you will need to repeat the if() statement for each set of element's you need to place in the email)

PHP:
/**
 * Will attempt to get the element for the posted key
 *
 * [USER=20939]param[/USER]   object  $formModel  Form model
 * [USER=20939]param[/USER]   string  $key        POST key value
 *
 * @return  array(label, is the key a raw element, should we show the element)
 */
function tryForLabel($formModel, $key)
{
$elementModel = $formModel->getElement($key);
$label = $key;
 
if ($elementModel)
{
$label = $elementModel->getElement()->label;
}
 
return $label;
}
echo "<table>";
$husoghjem = (array) $this->data['forsikringer___Husoghjem'];
 
if (in_array('Hus', $husoghjem))
{
  // Add all the fields you want to show, when Husoghjem = Hus, to the array
  $fields = array('forsikringer_2_repeat___Hustype', 'forsikringer_2_repeat___Utleid', 'forsikringer_2_repeat___Bygge');
  foreach ($fields as $field) {
    $label = tryForLabel($formModel, $field);
    echo "<tr><td>" . $label . "</td></td>" . $this->data[$field] . "</td></tr>";
  }
}
 
// Repeat for the next set of fields et al.:
 
if (in_array('Innbo', $husoghjem))
{
  // Add all the fields you want to show, when Husoghjem = Innbo, to the array
  $fields = array('forsikringer_3_repeat___Hystypeinnbo', 'forsikringer_3_repeat___Bygningstype');
  foreach ($fields as $field) {
    $label = tryForLabel($formModel, $field);
    echo "<tr><td>" . $label . "</td></td>" . $this->data[$field] . "</td></tr>";
  }
}
echo "</table>";
 
I really appreciate the help here. Thank you again. When I use this template I get the output which you can see below on the email send to me. It doesn't report the actual value I fill out in the form - it only report the label. Can you maybe spot the issue?

"
ArrayArrayArray
Hustype
Er mer enn 50 % av huset utleid?
Bygge?r
"
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top