Domanda

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.

È stato utile?

Soluzione

I think the reason it's not working is because the node element 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, nid and url) and then implement hook_webform_submission_insert() to save the current $_SERVER['REQUEST_URI'] for all webforms. You can then use hook_webform_submission_load() and hook_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.php file included in the module, they're pretty well documented.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top