You are here

function newsletter_subscribe_form in Newsletter 7

Loads up the form that is displayed to the newsletter block.

1 string reference to 'newsletter_subscribe_form'
newsletter_block_view in ./newsletter.module
Implements hook_block_view().

File

./newsletter.module, line 1346
Defines menu items for newsletter administration, permissions and basic drupal hooks.

Code

function newsletter_subscribe_form($form, &$form_state) {
  global $user;
  $ajax = array(
    'callback' => 'newsletter_subscribe_form_submit',
    'wrapper' => 'newsletter-error',
    'effect' => 'fade',
    'progress' => array(
      'type' => 'throbber',
      'message' => NULL,
    ),
    'event' => 'click',
  );
  if (!isset($user->mail) || variable_get('newsletter_show_email_in_block', FALSE)) {
    $form['email'] = array(
      '#type' => 'textfield',
      '#default_value' => t('user@example.com'),
      '#size' => 20,
      '#required' => TRUE,
    );
  }
  else {
    $form['logged-in'] = array(
      '#type' => 'hidden',
      '#value' => TRUE,
    );
  }
  $form['newsletter-submit'] = array(
    '#type' => 'submit',
    '#value' => t('Subscribe'),
    '#prefix' => '<div id="newsletter-error"></div><div id="subscribe">',
    '#suffix' => '</div>',
    '#ajax' => $ajax,
  );
  return $form;
}