You are here

public function ModalForm::submitForm in Editor Notes 8

Updates EditorNote entity.

Overrides FormInterface::submitForm

File

src/Form/ModalForm.php, line 219

Class

ModalForm
Implements the ModalForm form controller.

Namespace

Drupal\editor_note\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $title = $form_state
    ->getValue('title');
  if ($editor_note = $this
    ->getEditorNoteEntity($form_state)) {
    $note = $form_state
      ->getValue('editor_note');
    $new_note = [
      'value' => Xss::filterAdmin($note),
      // @todo: implement support for text formats.
      'format' => 'plain_text',
    ];
    $editor_note
      ->set('note', $new_note);
    $editor_note
      ->save();
  }
  $this->messenger
    ->addMessage($this
    ->t('Submit handler: You specified a title of @title.', [
    '@title' => $title,
  ]));
}