Hi there,
I'm using the redirect URL option for my Webform and I'm posting my form to an external URL. However, the field names are returned with names starting with "submitted[xxxxx]" and the requirement is that they are posted to the URL without it.

If anyone knows a solution to this or can give me a hint on how to change the value of the name="" attribute of any given form field prior to posting to an external URL, that would be appreciated. I guess this would involve some kind of string truncating and possibly placing it in the Additional processing field, but I'm not quite sure.

Comments

mkrakowiak’s picture

I came up with something like this below, but it's not doing the job...

 function clean_name($value) {
  $value = str_replace ( "submitted[your_information][", "", $value);
  $value = str_replace ( "submitted[give_now][", "", $value);
  $value = str_replace ( "submitted[give_monthly][", "", $value);
  $value = str_replace ( "]", "", $value);
  return $value;
}
foreach ($form_values['submitted'] as $field_id => $value) {
  $component = $node->webformcomponents[$field_id];
  $out = clean_name($component['name']);
}

Any ideas?

quicksketch’s picture

Are you sure you're using the 2.x version? The Redirect URL function was removed entirely in 2.x because of widespread confusion and extremely rare actual use.

Anything used in the Additional validation or submission fields will not have any effect because as the help text states, all processing by Webform is skipped entirely when using the redirect URL option.

I wouldn't recommend using Webform for this purpose at all. If you need to send form data to an external source you can either make a custom module or (really hacky) you can just make an HTML page containing the form, since it'll be processed by an external source anyway.

mkrakowiak’s picture

Thanks for your advice, quicksketch. Yesterday I started making a module that will handle the donation form. It's based on a multistep form (using FormAPI) and it seems like it will do the job. I wanted to avoid making an HTML page containing the form, since I don't really want to rely on a client-side (javascript) validation and small calculations.

Regarding the Redirect URL: I upgraded from 1.9 to 2.0-beta2 (and then to beta3), but it still shows "Confirmation message or redirect URL:" under Webform Settings. Or am I looking at a wrong thing?

quicksketch’s picture

Oh right. "Redirect URL" still exists, I was thinking about "Redirect POST". Redirect URL just means that's the page the user will be sent to after the processing of the form is completed. It's important to note that the $_POST variable isn't available at that URL (hence the redirect).

mkrakowiak’s picture

Good point. It was a bit confusing to me and this was one of the reasons that my form didn't work.

The conclusion is (just as you stated): use Webform for creating any "internal" forms, and Form API for sending form data to an external source.

quicksketch’s picture

Status: Active » Closed (fixed)

This discussion is done (I think?) Please reopen if you have further questions on this topic.

bailey86’s picture

I currently have the same issue.

I'm using the advice at:

https://drupal.org/node/1291574

on an old Drupal site.

The webform module is 6.x-3.9

and I'm having the same problem.

I.e. - the backend interface says 'This key will be used as the name attribute of the form element. ' for the field key - but when posting I'm getting the element names back with the 'submitted' prefix.

Was this fixed as an old bug? Or is it still an issue?

Thanks,

bailey86

bailey86’s picture

Version: 5.x-2.0-beta3 » 6.x-3.9
Component: Miscellaneous » Code
Category: support » bug

Set as bug report - I've looked at the release notes for the newer versions and is does not appear to have been fixed.