Hi,

Really simple, but allow a bit of flexibility of rendering submission:

--- webform.submissions.inc.old	2010-05-25 10:38:04.000000000 -0500
+++ webform.submissions.inc	2010-05-25 10:43:29.000000000 -0500
@@ -230,7 +230,7 @@
       _webform_client_form_add_component($component, NULL, $renderable, $renderable, $submission, $format);
     }
   }
-
+  $renderable = drupal_alter('webform_submission_render', $renderable);
   return drupal_render($renderable);
 }

with this patch we can use:

function MODULE_NAME_webform_submission_render_alter(&$renderable) {
  // ...
}

to easily alter data represented on submission report page.

also, patch with the same content attached for convenience.

Comments

pavel.karoukin’s picture

StatusFileSize
new385 bytes

oh. my bad. used this drupal_alter() in a wrong way. correct way to use:


--- webform.submissions.inc.old	2010-05-25 11:48:05.000000000 -0500
+++ webform.submissions.inc	2010-05-25 11:48:19.000000000 -0500
@@ -230,7 +230,7 @@
       _webform_client_form_add_component($component, NULL, $renderable, $renderable, $submission, $format);
     }
   }
-
+  drupal_alter('webform_submission_render', $renderable);
   return drupal_render($renderable);
 }
 

fixed patch attached =)

pavel.karoukin’s picture

StatusFileSize
new415 bytes

another revision - putting all variable used in render function =) (found this useful)


--- webform.submissions.inc.old	2010-05-25 11:48:05.000000000 -0500
+++ webform.submissions.inc	2010-05-25 13:52:31.000000000 -0500
@@ -230,7 +230,7 @@
       _webform_client_form_add_component($component, NULL, $renderable, $renderable, $submission, $format);
     }
   }
-
+  drupal_alter('webform_submission_render', $renderable, $submission, $email, $format);
   return drupal_render($renderable);
 }
 
quicksketch’s picture

Thanks, I think this is a good improvement, since the Webform renderable is essentially identical to the way forms are built, but we currently have no way of modifying the way Webform submissions are displayed.

The only caveat I see in this patch is that Drupal 7 only supports 3 parameters, but our patch here has 4. See http://api.lullabot.com/drupal_alter/7.

So to fix this problem the suggested approach is to introduce a $context variable and put everything in that variable. So our function would actually look like:

--- webform.submissions.inc.old 2010-05-25 11:48:05.000000000 -0500
+++ webform.submissions.inc 2010-05-25 13:52:31.000000000 -0500
@@ -230,7 +230,7 @@
       _webform_client_form_add_component($component, NULL, $renderable, $renderable, $submission, $format);
     }
   }
 
+  $context = array('submission' => $submission, 'email' => $email, 'format' => $format);
+  drupal_alter('webform_submission_render', $renderable, $context);
   return drupal_render($renderable);
}
quicksketch’s picture

Status: Needs review » Fixed
StatusFileSize
new2.4 KB

After some thought, I decided it would actually be most beneficial to simply combine the extra parameters into properties within the renderable (such as #node, #submission, and #email). This makes our renderable consistent with the addition of #node and #submission to the $form array in #821030: Bind $node and $submission to $form in webform_client_form.

I've committed this patch, thanks for your suggestions and please let me know if further changes seem like they would be necessary.

pavel.karoukin’s picture

Very nice! Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.