function RobotDeleteForm::submitForm
Same name in other branches
- 8.x-1.x config_entity_example/src/Form/RobotDeleteForm.php \Drupal\config_entity_example\Form\RobotDeleteForm::submitForm()
- 4.0.x modules/config_entity_example/src/Form/RobotDeleteForm.php \Drupal\config_entity_example\Form\RobotDeleteForm::submitForm()
The submit handler for the confirm form.
For entity delete forms, you use this to delete the entity in $this->entity.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: An associative array containing the current state of the form.
Overrides EntityForm::submitForm
File
-
modules/
config_entity_example/ src/ Form/ RobotDeleteForm.php, line 76
Class
- RobotDeleteForm
- Class RobotDeleteForm.
Namespace
Drupal\config_entity_example\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Delete the entity.
$this->entity
->delete();
// Set a message that the entity was deleted.
$this->messenger()
->addMessage($this->t('Robot %label was deleted.', [
'%label' => $this->entity
->label(),
]));
// Redirect the user to the list controller when complete.
$form_state->setRedirectUrl($this->getCancelUrl());
}