You are here

public function TemplateEditForm::submitForm in Courier 2.x

Same name and namespace in other branches
  1. 8 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 165

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 \Drupal\courier\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);
}