Sorry if this is a duplicate of a post but I've searched far and wide and still can not find a solution to my problem...

I'm trying to post the value of just one of the fields of the webfrom to a custom redirect but can't for the life of me figure out how to do this, I can do this done easily with a simple PHP script in a non-module way but I'd like to use webform so I can also keep a record onsite of the names of the people who have submitted the form...After a lot of googling I found and altered the found code for a module

// form_submit()
function dnalter_webform_submit($form, &$form_state) {

// Submited values are in $form_state['values']['submitted_tree']
$field_values = dnalter_webform_values( $form_state['values']['submitted']   );



// Build URL Query
$query = '';

foreach ($field_values as $value) {
    $query .= $value . '&';
}

$redirect = array ( 
                'http://url.com',
                array (
                    'query' => array ( 
                        'query' => rtrim( $query, "&" )  // Get 'query' values with $_GET['query']
                    ) 
                ) 
            );



$form_state['redirect'] = $redirect;

}

// Recurse through webfrom submited values
function dnalter_webform_values($component) {

static $webform;

foreach($component as $key => $value) {
    if (is_array($value)) {
        dnalter_webform_values($value);
    }
    else {
        $webform[$key] = $value;
    }
}

return $webform;

}

This gives me the values of all the fields but what I want to know is how can I get the value of just a specific one?

Just so you got a better idea of what I'm trying to accomplish the redirect url would read something like this:

http://url.com&amount=40 (where 40 is the value submitted in the webform)

Thanks in advance for any help

Comments

vin247’s picture

*bump* anyone???

liam morland’s picture

Install the devel module and call dsm($form_state). That will allow you to see what is in the variable and find the value you are looking for.

quicksketch’s picture

Category: task » support

You can also use tokens in the confirmation URL I believe. Just using %value[form_key] in the confirmation URL might be enough for your situation. This can also be done in the 4.x version with the token [submission:values:form_key:nolabel].

vin247’s picture

@Liam Morland I tried that, I know which value I'm looking for but it doesn't work, I just end up on the page without the required value unfortunetly

@quicksketch I did try tokens in the confirmation URL but that method doesn't seem to like the "=" symbol as when I try it it doesn't do anything, just reloads the same page the webform is on

quicksketch’s picture

What's the URL you're entering as your redirect (with tokens and all)? Webform should be able to handle extra query string variables with no problem.

vin247’s picture

The URL to direct to is as follows

https:///leukaemialymphomaresearch.org.uk/civicrm/contribute/transact?reset=1id=1&amount_other=%value[donation]&1&id=1&custom_218=Tribute Fund&1&id=1&custom_217=Tribute Fund&1&id=1&custom_220=Leukaemia

Actually because webform pops up with an error saying the URL is invalid I use a hidden field of which the default value is the url and use the token of that hidden field for the redirect. So what I actually put in the custom redirect field is %value[go_to] which holds the actual URL.

Anyway what's meant to happen is once it goes to that URL it populates a few text fields with the values in the URL.

I have a simple PHP script that can pull this off no problem but I want to use webform to keep records on in the drupal DB.

quicksketch’s picture

Hm, Webform is probably going to have a hard time parsing the URL. It looks malformed in a couple ways:

- Three slashes after the http:
- Repeated &1 in the query string, without values.
- No ampersand between reset=1 and id=1
- Repeated id=1 which won't have any effect.

Webform should be able to handle the tokens adequately, you might try using a simpler example and then build up the query incrementally. All told I would expect you'd have a URL more like this (removing all the invalid portions):

https://leukaemialymphomaresearch.org.uk/civicrm/contribute/transact?reset=1&id=1&amount_other=%value[donation]&custom_218=Tribute Fund&custom_217=Tribute Fund&custom_220=Leukaemia
vin247’s picture

three slashes was a typo but after fixing the malformed looking URL I'm still having no luck unfortunetly, if I remove the https:// it all gets executed fine but without the http it becomes an internal URL which is not what I'm after

alienzed’s picture

subscribing.

I'd like to add that I see no "Redirect POST values" option in the advanced options either in the main Webform configuration or on an individual webform's settings. Using the latest of everything....

quicksketch’s picture

Status: Active » Closed (duplicate)

I'd like to add that I see no "Redirect POST values" option in the advanced options

This feature hasn't existed for a very long time. You can emulate it with the Webform remote post module though.

Actually because webform pops up with an error saying the URL is invalid I use a hidden field of which the default value is the url and use the token of that hidden field for the redirect. So what I actually put in the custom redirect field is %value[go_to] which holds the actual URL.

There is an existing bug for this at #1244072: Use of tokens in external URL redirect locations not allowed in some cases and not URL Encoded.

Between both these questions I think the answers are found elsewhere, so I'm marking this duplicate.

quicksketch’s picture

Issue summary: View changes

added example of desire result