I want to have a single email field form on my page to suscribe to a newsletter and when the user submit this form, to redirect to a complete form (with name, surname...)

The complete form is designed with Webforms module and this single field form with the Form API in a custom module.

I'm using Drupal 6.25.

The problem is when I submit this form; I feel it don't send any POST parameters. I get them in Webform by setting a default value for the E-mail field at %post[newsletter_mail] and it doesn't work.

This is my code.

function block_contact_newsletter_form() {
  $form['description'] = array(
    '#type' => 'item',
    '#title' => t('Suscribe to Newsletter !')

  $form['newsletter_mail'] = array(
    '#type' => 'textfield',
    '#default_value' => t('Your E-mail')

  $form['submit'] = array(
    '#type' => 'submit', 
    '#value' => t('OK'),

  return $form;

function theme_block_contact_newsletter_form($form) {
  $output = '';
  $output .= drupal_render($form['description']);
  $output .= drupal_render($form['newsletter_mail']);
  $output .= drupal_render($form['submit']);
  $output .= drupal_render($form);

  return $output;

function block_contact_newsletter_form_theme() {
  $themes = array();

  $themes['newsletter_form'] = array(
    'arguments' => array(),

  return $themes;

function block_contact_newsletter_form_submit($form, &$form_state) {
  $link_newsletter = drupal_get_path_alias('node/'.variable_get('webform_newsletter_default_nid', ''), $language->language);
  if (strstr($path_newsletter, 'node/') !== FALSE) {
    $link_newsletter = drupal_get_path_alias('node/'.variable_get('webform_newsletter_default_nid', ''), 'fr');

  $form_state['redirect'] = $link_newsletter; 

function block_contact_default() {
  $content = array();
  $content[] = '<div class="logo">My.<span>Sitwe</span></div>';

  $items[] = array('class' => 'mail', 'data' => l(t("By mail"), 'node/'.variable_get('webform_contact_default_nid', FALSE)));
  $chat = variable_get('default_chat', "");
  if (!empty($chat)) {
    $items[] = array('class' => 'chat', 'data' => l(t("By chat"), variable_get('default_chat', "")));

  $facebook = variable_get('default_facebook', "");
  if (!empty($facebook)) {
    $items[] = array('class' => 'facebook', 'data' => l("Facebook", $facebook));

  $twitter = variable_get('default_twitter', "");
  if (!empty($twitter)) {
    $items[] = array('class' => 'twitter', 'data' => l("Twitter", 'http://twitter.com/'. $twitter));

// The interesting part for this function begins here.
  $items[] = array('class' => 'newsletter_form', 'data' => drupal_get_form('block_contact_newsletter_form'));

  $content[] = theme('item_list', $items);

  return array(
    'subject' => t("Contacts"),
    'content' => implode('', $content),
    'classes' => array('block-ot-contact')

Do you have any advice?

1 Answer 1


You're telling the form to submit via POST, and then once it's done submitting, to redirect to the webform. I think what you intended to do was to make the form submit its data straight to the webform, which you could do with the #action key in the $form array. See http://api.drupal.org/api/drupal/developer!topics!forms_api_reference.html/6#action

However, this isn't really a very robust approach. A better approach would be to put together your own webform, and then put that webform into a block. If you need to do any custom processing on the webform, the webform module has its own API and hooks that you can use.

  • Thank you for your answer ! I now use $form['#action'] instead of $form_state['redirect'] and I check into Network traffic in Google Chrome and my POST parameter is sent but I can't retrieve it in my Webform. Do you have an idea other than create a new Webform ? Thank you again
    – cocoggu
    May 23, 2012 at 10:15
  • That's a slightly different question! If you can see the POST is working properly, the original question has been answered. You should post a new question with a different title. May 23, 2012 at 10: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.