You are here

function newsletter_template_type_form in Newsletter 7.2

Form callback: create or edit a template type.

Parameters

$newsletter_template_type: The newsletter template type object to edit or create.

See also

newsletter_template_type_form_validate()

newsletter_template_type_form_submit()

newsletter_template_type_form_submit_delete()

NewslettertemplateTypeUIController::hook_menu()

File

modules/template/includes/newsletter_template.admin.inc, line 187
hook_menu callbacks for admin pages.

Code

function newsletter_template_type_form($form, &$form_state, $newsletter_template_type, $op = 'edit') {
  if ($op == 'clone') {
    $newsletter_template_type->name .= ' (cloned)';
    $newsletter_template_type->type = '';
  }
  $form_state['newsletter_template_type'] = $newsletter_template_type;
  $form['name'] = array(
    '#title' => t('Name'),
    '#type' => 'textfield',
    '#default_value' => $newsletter_template_type->name,
    '#description' => t('The human-readable name of this template type.'),
    '#required' => TRUE,
    '#size' => 30,
  );

  // Machine-readable type name.
  $form['type'] = array(
    '#type' => 'machine_name',
    '#default_value' => isset($newsletter_template_type->type) ? $newsletter_template_type->type : '',
    '#maxlength' => 32,
    //'#disabled' => $newsletter_template_type->isLocked() && $op != 'clone',
    '#machine_name' => array(
      'exists' => 'newsletter_template_get_types',
      'source' => array(
        'name',
      ),
    ),
    '#description' => t('A unique machine-readable name for this template type. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $form['data']['#tree'] = TRUE;
  $form['actions'] = array(
    '#type' => 'container',
    '#attributes' => array(
      'class' => array(
        'form-actions',
      ),
    ),
    '#weight' => 400,
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save template type'),
  );
  $form['actions']['delete'] = array(
    '#type' => 'submit',
    '#value' => t('Delete template type'),
    '#limit_validation_errors' => array(),
    '#submit' => array(
      'newsletter_template_type_form_submit_delete',
    ),
  );
  return $form;
}