You are here

public function ContactDeleteForm::submitForm in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/content_entity_example/src/Form/ContactDeleteForm.php \Drupal\content_entity_example\Form\ContactDeleteForm::submitForm()

Delete the entity and log the event. logger() replaces the watchdog.

Overrides ContentEntityForm::submitForm

File

content_entity_example/src/Form/ContactDeleteForm.php, line 44

Class

ContactDeleteForm
Provides a form for deleting a content_entity_example entity.

Namespace

Drupal\content_entity_example\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $entity = $this
    ->getEntity();
  $entity
    ->delete();
  $this
    ->logger('content_entity_example')
    ->notice('@type: deleted %title.', [
    '@type' => $this->entity
      ->bundle(),
    '%title' => $this->entity
      ->label(),
  ]);
  $form_state
    ->setRedirect('entity.content_entity_example_contact.collection');
}