You are here

function newsletter_subscriber_edit in Newsletter 7

Menu callback; edit subscribers.

2 string references to 'newsletter_subscriber_edit'
newsletter_menu in ./newsletter.module
Implements hook_menu().
newsletter_subscriber_add in includes/newsletter.admin.inc
Menu callback; add subscribers.

File

includes/newsletter.admin.inc, line 1028
Admin page callbacks for the newsletter module.

Code

function newsletter_subscriber_edit($form, &$form_state, $subscriber) {
  require_once DRUPAL_ROOT . '/includes/locale.inc';
  $countries = country_get_list();
  if (isset($subscriber->nsid)) {
    $form['edit'] = array(
      '#markup' => '<h3>' . t('Edit Subscriber') . '</h3>',
    );
    $form['nsid'] = array(
      '#type' => 'hidden',
      '#value' => (int) $subscriber->nsid,
    );
  }
  $form['email'] = array(
    '#type' => 'textfield',
    '#title' => t('E-mail'),
    '#required' => TRUE,
    '#default_value' => check_plain($subscriber->email),
    '#weight' => 0,
  );
  $form['additional'] = array(
    '#type' => 'fieldset',
    '#title' => t('Additional info'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
  );
  $form['additional']['firstname'] = array(
    '#type' => 'textfield',
    '#title' => t('First name'),
    '#default_value' => check_plain($subscriber->firstname),
  );
  $form['additional']['lastname'] = array(
    '#type' => 'textfield',
    '#title' => t('Last name'),
    '#default_value' => check_plain($subscriber->lastname),
  );
  $form['additional']['gender'] = array(
    '#type' => 'textfield',
    '#title' => t('Gender'),
    '#default_value' => check_plain($subscriber->gender),
  );
  $form['additional']['receive_format'] = array(
    '#type' => 'select',
    '#title' => t('Preferred Format'),
    '#options' => array(
      'html' => t('HTML'),
      'plain' => t('Plain text'),
    ),
    '#default_value' => check_plain($subscriber->receive_format),
  );
  field_attach_form('newsletter_subscriber', $subscriber, $form, $form_state);
  $form['actions'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'form-actions',
      ),
    ),
    '#weight' => 10,
  );
  $form['actions']['submitnew'] = array(
    '#type' => 'submit',
    '#value' => isset($subscriber->nsid) ? t('Update') : t('Save'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'link',
    '#title' => t('Cancel'),
    '#href' => 'admin/config/media/newsletter/subscribers',
  );
  return $form;
}