I’m using a webform as a block on all the pages from a specific content type. The form is the same in all, but on the list of submissions I want to know which page the user was seeing. I thought a hidden field, and a default value of %title would do it, but it’s not the case. I tried a bunch of other token values, and a lot of them do work, but none of them gives me an identifier of the current node.
I’m using a webform as a block on all the pages from a specific
Share
I think the reason it’s not working is because the
nodeelement of the webform tokens refers to the node of the webform itself, not the current node page. Why webform doesn’t use the in-built token system I have no idea, seems like a missed opportunity.Looking at the webform module I think the easiest way to get this done is to write a quick custom module defining a single table (two columns,
nidandurl) and then implementhook_webform_submission_insert()to save the current$_SERVER['REQUEST_URI']for all webforms. You can then usehook_webform_submission_load()andhook_webform_submission_render_alter()respectively to re-attach the URL data to the submission and display it to the page.You can find all of those hooks in the
webform_hooks.phpfile included in the module, they’re pretty well documented.