public function TypeBundleDeleteConfirm::buildForm in Booking and Availability Management Tools for Drupal 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EntityDeleteForm::buildForm
File
- modules/
bat_unit/ src/ Form/ TypeBundleDeleteConfirm.php, line 21 - Contains \Drupal\bat_unit\Form\TypeBundleDeleteConfirm.
Class
- TypeBundleDeleteConfirm
- Provides a form for unit type bundle deletion.
Namespace
Drupal\bat_unit\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
$entity = $this
->getEntity();
// Check if types of a type bundle exist before allowing deletion.
$type_bundle = $entity
->id();
if (count(bat_type_load_multiple([], [
'type' => $type_bundle,
]))) {
// This type bundle has associated types, don't allow deletion.
$this
->messenger()
->addError(t('This Bat Type bundle has associated Types. Please delete all Types before attempting to delete this Bat Type bundle.'));
return [];
}
return $form;
}