You are here

function newsletter_template_edit in Newsletter 7

3 string references to 'newsletter_template_edit'
newsletter_basic_template_edit in includes/newsletter.admin.inc
Menu callbacks; edit basic or non-basic newsletter templates.
newsletter_menu in ./newsletter.module
Implements hook_menu().
newsletter_template_add in includes/newsletter.admin.inc
Menu callback; add a newsletter template.

File

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

Code

function newsletter_template_edit($form, &$form_state, $template) {
  if (isset($template->ntid)) {
    $form['id'] = array(
      '#type' => 'hidden',
      '#value' => (int) $template->ntid,
    );
  }
  $form['subject'] = array(
    '#type' => 'textfield',
    '#default_value' => check_plain($template->subject),
    '#title' => t('Subject'),
    '#description' => t('This will also used as newsletter title.'),
    '#weight' => -10,
    '#required' => TRUE,
  );
  $form['token_help'] = array(
    '#title' => t('Replacement patterns'),
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#description' => $template->basic ? '' : t('Use [repeat] and [/repeat] for recurring items such as nodes'),
  );
  $form['token_help']['help'] = array(
    '#theme' => 'token_tree',
    '#token_types' => $template->basic ? array(
      'site',
      'newsletter',
      'newsletter_list',
      'newsletter_subscriber',
      'newsletter_template',
    ) : array(
      'site',
      'node',
      'term',
      'newsletter',
      'newsletter_list',
      'newsletter_subscriber',
      'newsletter_template',
    ),
    '#recursion_limit' => 2,
  );
  field_attach_form('newsletter_template', $template, $form, $form_state);
  $form['exposed'] = array(
    '#type' => 'checkbox',
    '#default_value' => $template->exposed,
    '#title' => t('Exposed'),
    '#weight' => 9,
  );
  $form['actions'] = array(
    '#type' => 'item',
    '#weight' => 10,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => isset($template->ntid) ? t('Update') : t('Save'),
  );
  $form['actions']['cancel'] = array(
    '#type' => 'link',
    '#title' => t('Cancel'),
    '#href' => 'admin/config/media/newsletter/templates',
  );
  return $form;
}