public function EmailForm::form in Courier 2.x
Same name and namespace in other branches
- 8 src/Form/EmailForm.php \Drupal\courier\Form\EmailForm::form()
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ EmailForm.php, line 28
Class
- EmailForm
- Form controller for email.
Namespace
Drupal\courier\FormCode
public function form(array $form, FormStateInterface $form_state, EmailInterface $email = NULL) {
$form = parent::form($form, $form_state);
/** @var \Drupal\courier\Entity\Email $email */
$email = $this->entity;
if (!$email
->isNew()) {
$form['#title'] = $this
->t('Edit email');
}
$template_collection = TemplateCollection::getTemplateCollectionForTemplate($email);
$form['tokens'] = [
'#type' => 'container',
'#weight' => 51,
];
$form['tokens']['list'] = $this
->templateCollectionTokenElement($template_collection);
$form['tokens']['help']['#prefix'] = '<p>';
$form['tokens']['help']['#markup'] = $this
->t('Tokens are replaced in subject and body fields.');
$form['tokens']['help']['#suffix'] = '</p>';
return $form;
}