1

I am creating a website for my department at work using Drupal 7. I have a webform designed in a page named Registration in the website. When a user fills this form in and submits, it sends a confirmation to me. I am also able to view the submissions using the Results tab in the webform using admin rights.

Now I am creating an other page(named 'approve request') for an editor role who approves the submission of the user. This Approve request page has been created in the content type that enables the webform. Now, I need the webform results from the Registration page to appear in the Approve request page. This will enable the Editor to view the Registration results and approve them.

How do I retrieve the results from the registration page to the Approval page? I looked at various sources and could not find a good answer. Please let me know.

Thanks in advance!

1 Answer 1

0

You can programmatically modify the form of Approve Request webform using hook_form_alter() function. In this form you can retrieve the previous webform submission entries and append in the Approve Request form.

You can retrieve previous webform submission using following snippet:

include_once(drupal_get_path('module', 'webform') .'/includes/webform.submissions.inc');
$nid = arg(1); // need to hard-code nid if this is a custom page you can manage dynamically also
$sid = $_GET['sid'];
$submission = webform_get_submission($nid, $sid);
7
  • Thanks. I made the change in the hook_form_alter in the webform module. The Registration page is node 24 and hence added the following code in my function. It did not get the results for me. function webform_form_alter(&$form, $form_state, $form_id) { include_once(drupal_get_path('module', 'webform') .'/includes/webform.submissions.inc'); $nid = arg(24); // need to hard-code nid if this is a custom page you can manage dynamically also $sid = $_GET['sid']; $submission = webform_get_submission($nid, $sid); } I am not sure if I am missing something.
    – user9890
    Commented Sep 17, 2012 at 17:34
  • In Stack Exchange we accepts answers to tell thanks.. Please accept the answer for better understanding of other people also. Commented Sep 18, 2012 at 4:15
  • since it was not working for me I wanted to confirm it with you before I could accept the answer. Apologies. Please see my comment above for details on the snippet that did not work for me. Thank you.
    – user9890
    Commented Sep 18, 2012 at 4:37
  • just a moment.. sharing you the detailed code Commented Sep 18, 2012 at 4:42
  • but at $nid = arg(1) should be there, why you return arg(24). arg(1) means www.example.com/node/24 then arg(0) is 'node' and arg(1) is 24 which is 'nid' Commented Sep 18, 2012 at 4:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.