You are here

public function PetForm::buildForm in Previewable email templates 8.4

Same name and namespace in other branches
  1. 8 src/Form/PetForm.php \Drupal\pet\Form\PetForm::buildForm()
  2. 8.3 src/Form/PetForm.php \Drupal\pet\Form\PetForm::buildForm()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides EntityForm::buildForm

File

src/Form/PetForm.php, line 16

Class

PetForm
PetForm class.

Namespace

Drupal\pet\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildForm($form, $form_state);
  $form['mimemail'] = [
    '#type' => 'details',
    '#title' => t('Mime Mail options'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
    '#open' => TRUE,
  ];
  $form['send_plain']['#group'] = 'mimemail';
  $form['mail_body_plain']['#group'] = 'mimemail';
  $form['mimemail']['#description'] = t('HTML email support is most easily provided by the <a href="@url">Mime Mail</a> module, which must be installed and enabled.', [
    '@url' => 'http://drupal.org/project/mimemail',
  ]);

  // @todo : #2366853 - Mime mail integration
  if (!pet_has_mimemail()) {
    unset($form['mail_body_plain']);
    unset($form['send_plain']);
  }
  $form['advanced'] = [
    '#type' => 'details',
    '#title' => t('Additional options'),
    '#open' => FALSE,
    '#access' => \Drupal::currentUser()
      ->hasPermission('administer previewable email templates'),
  ];
  $form['cc_default']['#group'] = 'advanced';
  $form['bcc_default']['#group'] = 'advanced';
  $form['from_override']['#group'] = 'advanced';
  $form['recipient_callback']['#group'] = 'advanced';
  $form['actions']['submit']['#value'] = t('Save Template');
  $form['tokens'] = pet_token_help();
  return $form;
}