public function TourTipDeleteForm::submitForm in Tour UI 8
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/ TourTipDeleteForm.php, line 109
Class
- TourTipDeleteForm
- Builds the form to delete a tour tip.
Namespace
Drupal\tour_ui\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
// Rebuild the tips and remove the irrelevant one.
$candidate = $this->tip
->get('id');
$tips = [];
foreach ($this->entity
->getTips() as $tip) {
$tip_id = $tip
->get('id');
if ($tip_id == $candidate) {
continue;
}
$tips[$tip_id] = $tip
->getConfiguration();
}
$this->entity
->set('tips', $tips);
$this->entity
->save();
$form_state
->setRedirect('entity.tour.edit_form', [
'tour' => $this->entity
->id(),
]);
$this->messenger
->addMessage($this
->t('Deleted the %tour tour %tip tip.', [
'%tour' => $this->entity
->label(),
'%tip' => $this->tip
->get('label'),
]));
}