You are here

public function TemplateEditForm::submitForm in Courier 8

Same name and namespace in other branches
  1. 2.x src/Form/TemplateEditForm.php \Drupal\courier\Form\TemplateEditForm::submitForm()

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

src/Form/TemplateEditForm.php, line 163

Class

TemplateEditForm
Create a message.

Namespace

Drupal\courier\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  /** @var \Drupal\courier\ChannelInterface $message */
  $message = $form_state
    ->get('message_entity');

  /** @var TemplateCollectionInterface $template_collection */
  $template_collection = $form_state
    ->get('template_collection');
  $form_state
    ->get([
    'form_display',
  ])
    ->extractFormValues($message, $form, $form_state);
  $message
    ->save();
  $response = new AjaxResponse();
  $response
    ->addCommand(new CourierTemplate($template_collection
    ->id(), $message
    ->getEntityTypeId(), 'close'));
  $form_state
    ->setResponse($response);
}