You are here

function mailing_list_email_form in Mailing List 6

Form to add / edit an e-mail in a mailing list.

1 string reference to 'mailing_list_email_form'
mailing_list_menu in ./mailing_list.module
Implementation of hook_menu().

File

./mailing_list.admin.inc, line 149
Mailing list admin UI.

Code

function mailing_list_email_form(&$form_state, $list = null, $email = null) {
  if (empty($list)) {
    return;
  }
  if (empty($email)) {
    drupal_set_title(t('Add e-mail'));
  }
  else {
    drupal_set_title(t('Edit e-mail'));
  }
  $form = array();
  if (isset($form_state['values']['mlid']) || isset($list)) {
    $form['mlid'] = array(
      '#type' => 'hidden',
      '#value' => isset($form_state['values']['mlid']) ? $form_state['values']['mlid'] : isset($list) ? $list->mlid : null,
    );
  }
  if (isset($form_state['values']['ml_name']) || isset($list)) {
    $form['ml_name'] = array(
      '#type' => 'hidden',
      '#value' => isset($form_state['values']['ml_name']) ? $form_state['values']['ml_name'] : isset($list) ? $list->name : null,
    );
  }
  if (isset($form_state['values']['eid']) || isset($email)) {
    $form['eid'] = array(
      '#type' => 'hidden',
      '#value' => isset($form_state['values']['eid']) ? $form_state['values']['eid'] : isset($email) ? $email->eid : null,
    );
  }
  $form['mail'] = array(
    '#title' => t('E-mail'),
    '#type' => 'textfield',
    '#required' => TRUE,
    '#default_value' => isset($form_state['values']['mail']) ? $form_state['values']['mail'] : isset($email) ? $email->mail : '',
  );
  $form['name'] = array(
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#default_value' => isset($form_state['values']['name']) ? $form_state['values']['name'] : isset($email) ? $email->name : '',
  );
  $form['submit'] = array(
    '#value' => t('Save'),
    '#type' => 'submit',
    '#submit' => array(
      'mailing_list_email_form_submit',
    ),
  );
  $form['#validate'][] = 'mailing_list_subscription_form_validate';
  $form['#redirect'] = 'admin/build/mailing-list/' . $list->mlid;
  return $form;
}