0
votes

The problem i'm facing is that i have a list of let's say 5 jobs. Each job had it's own page and at the bottom of that page i have a button to apply for this job.

Now when you click the button a webform opens on a new page that you need to fill in in order to apply for that job.

The problem here is that when we receive mails, we don't know for what job they are applying.

A possible sollution would be to just pass the node title to a field in the webform or just in the mail they receive. But i can't seem to get this working.

I'm using the webforms module and the site is made in Drupal 8. suggestions are welcome in order to solve this issue.

3

3 Answers

0
votes

A possible solution for this issue is that you can add a field of type "hidden" in your webform and set value from the available tokens like page title or url.

For eg: To set page title you can add value as

[current-page:title]

Don't know whether we can add a node title into it

--OR--

You can create it as a node or block it is well explained in this video

https://www.youtube.com/watch?v=xYBW2g0osd4

0
votes

I'd highly suggest separating each job application form out and duplicating a template "job application" webform for each one so they're not all going to the same place. This will bring more clarity to your overall process and eliminate that issue.

Webforms for Drupal 8 provides pretty good templating options, so even if you don't have access to the content types/webforms backend yourself, an administrator should be able to create a "job application" template that you can create each time when you create a new job posting.

EDITED TO ADD:

You could also use a little php to get the page that sent you to the webform:

$ref = @$_SERVER[HTTP_REFERER]; //get referrer link
$nid = end(explode("/",$ref));  //get nid of referrer
$node_title = node_load($nid)->title; //get title of referring node

Where you put this code would depend on your overall setup, but you could likely add it to a field's default value.

0
votes
  1. Create a entity reference field called "Attached Webform" on your node type
  2. Set the default value of "Attached Webform" to your webform.
  3. Do not display this field by going to form display settings and dragging "Attached Webform" to hidden.

Afterwards, you can access the node data through tokens, e.g. [webform_submission:node:title]

Also, if you edit the source of the webform, you can set the title of the form using:

'#title': 'Contact [webform_submission:node:title]'
name:
  '#title': 'Your Name'
  '#type': textfield
  '#required': true
  '#default_value': '[current-user:display-name]'
# ...