1

This post is the continuation of this question : Form isn't sending POST parameters?

I now have difficulties to retrieve my parameters in a Webform. In Chrome, I can see that my parameter is sent but the POST header have a "302 Moved Temporarily" status

In my webform I try to get my parameter with %post[email] but it don't works

Here is my code using the Form API in a custom module (see my old post for more informations)

function gn_ot_block_contact_newsletter_form()
{
  $form = array();

  $link_newsletter = drupal_get_path_alias('node/'.variable_get('gn_ot_webform_newsletter_default_nid', ''), $language->language);
  if(strstr($path_newsletter, 'node/') !== FALSE){
    $link_newsletter = drupal_get_path_alias('node/'.variable_get('gn_ot_webform_newsletter_default_nid', ''), 'fr');
  }

  $form['#action'] = base_path() . $link_newsletter;
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('INSCRIVEZ-VOUS A LA NEWSLETTER !')
  );    
  $form['email'] = array(
    '#type' => 'textfield',
    '#default_value' => t('Votre adresse e-mail')
  ); 
  $form['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('OK'),
  );

  return ($form);
}

I'm using Drupal 6.25. Thank you if you have any advice !

  • Why you create WebForm programmatically? What is you goal? – Codium May 23 '12 at 11:43
  • No my Webform isn't create with code. I have my Webform on a page and a single-field form (in a custom block) on my index page (with email field). My goal is to automatically complete email field on the full newsletter webform with data from my custom single-field form. – cocoggu May 23 '12 at 11:51
  • So I don't understand your problem at all. Provide more info, please. – Codium May 23 '12 at 11:53
  • So email field is visible only in one-field form? – Codium May 23 '12 at 11:57
  • I have two email fields : One in my one-field form on index page and the second in my full Webform which I want to be automatically filled when submitting the first one. – cocoggu May 23 '12 at 12:02
3

You need to use hook_form_alter to change value of full form email field. Just take value from table or session where you save one-field email result per user.

| improve this answer | |
  • Can I use Webform configuration to change default value ? Because when I put a default value for my Webform field (%post[email]) and I create my form with Full HTML, it works. But when I use the Form API it failed with this "303 Moved Temporarly" warning for the POST header. Really sorry for difficulties I have to explain my problems.. – cocoggu May 23 '12 at 12:26
  • 1
    IMHO it is because after on-field form submission you getting redirect, so that why is 303. You can disable redirection in form settings as I am concerned – Codium May 23 '12 at 12:30
  • You're my hero ! With your recommendations I add $form['#redirect'] = FALSE; in my code and it works like a charm. Thank you very much :D ! – cocoggu May 23 '12 at 12:35
  • Glad I can help – Codium May 23 '12 at 12:36

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.