1

I have a capture form in a block on a panel, and I am trying to get it to post the values to another form, once it is submitted.

How can I achieve this?

First name, last name, and email get posted to example.com/page?fname=XXX&lname=YYY&email=ZZZ.

I am using Drupal 6, and the Webform module version 3.9.

  • What module handles what you call, "another form"? – kiamlaluno Feb 29 '12 at 18:55
  • Yes, i have a module that is rendering a join form ... – Matthew Woodard Feb 29 '12 at 18:59
  • I mean which one: a custom module, a Drupal core module, or a module that can be downloaded from Drupal.org. In the last two cases, knowing exactly which module is could be relevant. – kiamlaluno Feb 29 '12 at 19:09
  • It is a custom module ... and here is an example of how i am building the form ... pastie.org/3490496 – Matthew Woodard Feb 29 '12 at 19:18
1

You should be able to use one of the webform hooks to pass $_GET values via redirect.

function YOURMODULE_webform_submission_insert($node, $submission) {
  if ($node->nid == XXX){
    // Grab the values we need and create our get url parameter string. 
    $queryString = 'f1=' . $submission['value']['myfield'] . '&f2=' . $submission['value']['myfield2'] . '&f3=' . $submission['value']['myfield2'];
    drupal_goto('PATH/TO/FORM', $queryString);
  }
}

Or you can use a hook_form_alter for that form, add a new submit callback, and in the new function set the form's #redirect with the same syntax.

$queryString = $form_state['value']['myfield'] . '&f2=' . $form_state['value']['myfield2'] . '&f3=' . $form_state['value']['myfield2'];
$form['#redirect'] = array('PATH/TO/FORM', $queryString);

Then in your custom form, check for the $_GET values, and set them as the defaults to the appropriate fields, if they exist.

0

You could set the #value property of the relevant elements based on the $_GET values.

  • Right, but how to i get the webform to post those value to the url? – Matthew Woodard Feb 29 '12 at 19:00
  • I shouldn't have talked about $_GET, but about $_POST, which is the variable used. It may not be usable though, given your sample code above. Maybe setting variables in $_SESSION would be a better way to go. – Countzero Mar 1 '12 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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