Browse Source

fixed whitescreens when clicking edit on the my reservations page for a reservation where the room no longer exists

d11-dev
Paul Pound 2 weeks ago
parent
commit
201d1c5ce7
  1. 16
      reservation.inc

16
reservation.inc

@ -88,7 +88,21 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte
reserve_set_modal_message($form, $max_reservations_exceeded_message);
}
}
$entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($eid);
$entity_type_manager = \Drupal::entityTypeManager();
$entity = ($entity_type && $eid && $entity_type_manager->hasDefinition($entity_type))
? $entity_type_manager->getStorage($entity_type)->load($eid)
: NULL;
// The reservable item may have been deleted (or the URL is invalid); don't
// fatal - show a message and only leave the form actions (e.g. Delete).
if (!$entity) {
reserve_set_modal_message($form, t('The item this reservation is for no longer exists.'));
foreach (\Drupal\Core\Render\Element::children($form) as $key) {
if (!in_array($key, ['actions', 'message', 'form_build_id', 'form_token', 'form_id'])) {
$form[$key]['#access'] = FALSE;
}
}
return;
}
$bundle = $entity->bundle();
$date = date('l, M d, Y', strtotime($d));
$time = reserve_display_time($t);

Loading…
Cancel
Save