I am trying to hide the edit and eelete links in the operations menu under structure -> menu for specific roles.
I was just trying to hide the operations dialog at all by this code but it returns an:
Error: Cannot unset string offsets in my_menu_form_menu_edit_form_alter()
/**
* @Implements hook_form_FORM_ID_alter().
*/
function my_menu_form_menu_edit_form_alter(&$form, FormStateInterface $form_state) {
dpm($form);
foreach ($form['links']['links'] as $index => $link) {
if (strpos($index, 'menu_link') !== false){
dpm($form['links']['links'][$index]['operations']['#links']);
unset($form['links']['links'][$index]['operations']);
}
}
I too tried to change just the title of a link but that didn't work either and resulted with the same error.
In D7 you just could do something like $form[$key]['operations']['edit']['#access'] = FALSE;
Help :-)