You are here

function mailchimp_subscribe_anon_form_all in Mailchimp 7

Same name and namespace in other branches
  1. 6.2 mailchimp.module \mailchimp_subscribe_anon_form_all()

Return a form for all available MC lists

Parameters

<type> $form_state:

<type> $list MC list object:

<type> $q MC object:

Return value

<type> form array

1 string reference to 'mailchimp_subscribe_anon_form_all'
mailchimp_subscribe_page in ./mailchimp.module
Return all available MC lists a given user can subscribe to

File

./mailchimp.module, line 488
Mailchimp module.

Code

function mailchimp_subscribe_anon_form_all($form, $form_state, $q) {
  $form = array(
    '#tree' => TRUE,
  );
  global $user;
  $lists = _mailchimp_get_available_lists($user);
  foreach ($lists as $list) {
    $form['mailchimp_lists'][$list->id] = array(
      '#type' => 'fieldset',
      '#title' => t('@name', array(
        '@name' => $list->name,
      )),
      '#description' => t('@desc', array(
        '@desc' => $list->description,
      )),
      '#collapsible' => TRUE,
      '#collapsed' => FALSE,
    );
    _mailchimp_subscribe_anon_form($list, $q, $form['mailchimp_lists'][$list->id]);

    // for anonymous sign up forms, we want to force email to be optional
    if ($form['mailchimp_lists'][$list->id]['EMAIL']) {
      $form['mailchimp_lists'][$list->id]['EMAIL']['#required'] = FALSE;
    }
  }
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Sign Up!'),
    '#weight' => 100,
  );
  $form['#submit'][] = 'mailchimp_subscribe_anon_form_submit';
  return $form;
}