Skip to content
Snippets Groups Projects
Commit acd13be8 authored by git's avatar git Committed by Dylan Donkersgoed
Browse files

Issue #2744329 by phillipHG, ieguskiza: Rabbit Hole form appears on a node delete form

parent 50a24fe7
No related branches found
No related tags found
No related merge requests found
......@@ -58,9 +58,11 @@ function rabbit_hole_form_alter(&$form, FormStateInterface $form_state, $form_id
->loadSupportedGlobalForms();
if (method_exists($form_state->getFormObject(), 'getEntity')) {
$current_type = $form_state->getFormObject()->getEntity()->getEntityTypeId();
$current_operation = $form_state->getFormObject()->getOperation();
$disallowed_operations = array('delete', 'cancel');
$administer_permitted = \Drupal::currentUser()
->hasPermission('rabbit hole administer ' . $current_type);
if (in_array($current_type, $affected_types) && $administer_permitted) {
if (in_array($current_type, $affected_types) && $administer_permitted && !in_array($current_operation, $disallowed_operations)) {
\Drupal::service('rabbit_hole.form_mangler')->addRabbitHoleOptionsToEntityForm(
$form, $form_state->getFormObject()->getEntity(), $form_state, $form_id);
......@@ -69,7 +71,7 @@ function rabbit_hole_form_alter(&$form, FormStateInterface $form_state, $form_id
array('_rabbit_hole_general_form_submit'))
);
}
elseif (in_array($current_type, $affected_bundle_types)) {
elseif (in_array($current_type, $affected_bundle_types) && !in_array($current_operation, $disallowed_operations)) {
\Drupal::service('rabbit_hole.form_mangler')->addRabbitHoleOptionsToEntityForm(
$form, $form_state->getFormObject()->getEntity(), $form_state, $form_id);
$form_state->setSubmitHandlers(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment