In v 2.x of webform, $form_values was available in the .tpl.php templates. In v 3.x, $form_values is not availablie but $submission is. However, it only includes a simple $data array with integer indices rather than using the original form keys, which makes it much harder to create the template. What is the rationale for this and is there a simple way to recover those keys to make creating the template simpler?

Thanks kindly.

Comments

kinnel’s picture

Priority: Minor » Normal
quicksketch’s picture

The $submission variable is now used because it allows things like the re-sending of e-mails afterwards without resubmitting the entire form. It also allows for restructuring the form without affecting the e-mail theming. If you'd like to avoid using the raw values, you can always just use the available tokens. The need for theming at all is largely negated by the use of %value and %email tokens in the built-in templating interface.

kinnel’s picture

Thanks for your response. Let me see if I can clarify. Below is a snippet of my template from version 6-2.x. Are there individual tokens available so I can get templating as fine-grained as this? To get the information from the $submission variable, I would need to figure out which array index would correspond to each form key.

  print "CONTACT INFO-----\n";
  print '  '.$form_values['submitted_tree']['contact_info']['contact_name']."\n";
  print '  '.$form_values['submitted_tree']['contact_info']['company']."\n";
  print '  '.$form_values['submitted_tree']['contact_info']['e_mail']."\n";
  print '  '.$form_values['submitted_tree']['contact_info']['phone']."\n\n";
  if ($form_values['submitted_tree']['contact_info']['street_address_1'] <>'') {
  	print '  '.$form_values['submitted_tree']['contact_info']['street_address_1']."\n";
  }
  if ($form_values['submitted_tree']['contact_info']['street_address_2'] <> '') {
  	print '  '.$form_values['submitted_tree']['contact_info']['street_address_2']."\n";
  }
  if ($form_values['submitted_tree']['contact_info']['city_state_zip'] <> '') {
  	print '  '.$form_values['submitted_tree']['contact_info']['city_state_zip']."\n\n";
  }
  print '  '.$form_values['submitted_tree']['contact_info']['country']."\n\n";

Thanks again and cheers.

quicksketch’s picture

I believe you can just use tokens such as %value[contact_info][contact_name] and use the built-in templating interface and accomplish the same result.

quicksketch’s picture

Status: Active » Closed (fixed)

Closing after lack of activity.