public function DeleteTermsForm::submitForm in Taxonomy Manager 8
Same name and namespace in other branches
- 2.0.x src/Form/DeleteTermsForm.php \Drupal\taxonomy_manager\Form\DeleteTermsForm::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/ DeleteTermsForm.php, line 87
Class
- DeleteTermsForm
- Form for deleting given terms.
Namespace
Drupal\taxonomy_manager\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$taxonomy_vocabulary = $form_state
->getValue('voc');
$selected_terms = $form_state
->getValue('selected_terms');
$delete_orphans = $form_state
->getValue('delete_orphans');
$info = TaxonomyManagerHelper::deleteTerms($selected_terms, $delete_orphans);
$this
->messenger()
->addMessage($this
->t("Deleted terms: %deleted_term_names", [
'%deleted_term_names' => implode(', ', $info['deleted_terms']),
]));
if (count($info['remaining_child_terms'])) {
$this
->messenger()
->addMessage($this
->t("Remaining child terms with different parents: %remaining_child_term_names", [
'%remaining_child_term_names' => implode(', ', $info['remaining_child_terms']),
]));
}
$form_state
->setRedirect('taxonomy_manager.admin_vocabulary', [
'taxonomy_vocabulary' => $taxonomy_vocabulary
->id(),
]);
}