Score:0

Over-ride entity delete button permission

th flag

created a Form View mode and some custom permissions (pre node, based on a user list field in the node). I want a user with that permission to be able to delete the node as well, and have added a delete button using hook_form_alter:

                $route_info = $room->toUrl('delete-form');  // need to use a custom handler to overright the delete controls.

                $form['actions']['delete'] = [
                    '#type' => 'link',
                    '#title' => t('Delete'),
                    '#access' => true,
                    '#weight' => 999,
                    '#attributes' => [
                        'class' => [
                          'button',
                          'button--danger',
                        ],
                    ],
                ];
                $form['actions']['delete']['#url'] = $route_info;

This of course gives me an 'access denied'. Is there a way to over-ride this so if the user has access to the delete button they can delete the node, but still using the standard Drupal confirm delete / delete handlers?

I know I can write a custom handler for this button, but was just thinking there may be a better way?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.