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?