Webform 6.x-3.18 Additional Processing Code help

jessSchn's picture

Hello,

I recently updated to Webform 6.x-3.18 and I noticed with this update that I no longer have the Additional Processing field (located under Webform Advanced Settings). I did some research to see how I can still make my form work and I came across a few pages:

http://drupal.org/node/1291574
http://drupal.org/node/1050656
http://www.drupalcoder.com/blog/additional-processing-in-drupals-webform...

So I decided to give the module approach a try (I've never had a module really work before, but there is a first time for everything, right?)

Before I start pasting code and asking for help; I'll explain what it is I need to accomplish first.

I have a class registration webform that is getting passed a node id for the specific class in the url (mywebsite.com?inid=9247). When you access the webform there is some markup code that announces what class you are signing up for:

<?php
if (isset($_GET['inid'])) {
$node = node_load($_GET['inid']);
$class = node_load($node->field_training_class[0]['nid']);

print
'<div class="messages">You are registering for: <strong>' . $class->title . '</strong></div>';
} else {
print
'<div class="messages error">Warning: No class ID is set. You must have arrived at this form by error...</div>';
}

?>

I also have two hidden fields on this form (class and cost - default value is blank/empty). When a user clicks submit on the form the additional processing code would fill in the class value (which is the class title) and the cost value (the cost associated with the class). These hidden fields and user information fields are then emailed to the event organizer.

I have setup a module to now handle the additional processing code:

mywebform_extra.info

name = Webform Extra
description = Customizations for the Webform module.
core = 6.x
package = Webform
dependencies[] = webform

mywebform_extra.module

<?php
/<strong>
*
Implementation of hook_form_alter().
*/
function
mywebform_extra_form_alter(&$form, &$form_state, $form_id) {
 
// Add validation for a particular Webform node:
 
if ($form_id == 'webform_client_form_3169') {
   
// Simply add the additional validate handler.
   
$form['#validate'][] = 'mywebform_extra_validate_3169';

   
// Add the submit handler after the existing Webform submit handler,
    // but before the second Webform handler. Pop off the first one and add
    // ours second.
   
$first = array_shift($form['#submit']);
   
array_unshift($form['#submit'], $first, 'mywebform_extra_submit_3169');
  }
}

/</
strong>
*
Validation handler for Webform ID #3169.
*/
//This function is commented out because anyone can sign up for a class.
/*function mywebform_extra_validate_3169(&$form, &$form_state) {
  global $user;
  if (!isset($user->roles[4])) {
    form_set_error('', t('Your user role is not allowed to submit this Webform.'));
  }
}*/

/**
* Submit handler for Webform ID #3169.
*/
function mywebform_extra_submit_3169(&$form, &$form_state) {
  global
$user;

 
// Changes can be made to the Webform node settings by modifying this variable:
 
$form['#node']->webform;

 
// Insert things into other database tables or modify properties.
  // The below code is copy and pasted from the additional processing field.
$instance= node_load($form_values['submitted_tree']['instance_nid']);
$class= node_load($instance->field_training_class[0]['nid']);

$form_values['submitted'][17] = $class->title . " on " . $instance->field_datetime[0]['value'];
$form_values['submitted_tree']['class'] = $class->title . " on " . $instance->field_datetime[0]['value'];
//$form_values['submitted']['class'] = $class->title . " on " . $instance->field_datetime[0]['value'];
$form_values['submitted'][19] = $class->field_class_cost[0]['value'];
$form_values['submitted_tree']['cost'] = $class->field_class_cost[0]['value'];
//$form_values['submitted']['cost'] = $class->field_class_cost[0]['value'];
 
}
?>

I'm not 100% sure what exatly is happening above - I didn't write the additional processing code.

From my testing with this new module (that I did enable and did flush all site caches), my class and cost hidden field values are not getting filled in on the email that gets sent out.

Can I get some guidance on this please? Thank you.

Comments

Different way

jessSchn's picture

Okay, so I just ended up passing the class title through the URL and then pulling the class title from the url into the hidden field.

Twin Cities

Group organizers

Group events

Add to calendar

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week