Score:-1

Remove actions (edit button) with hook_views_pre_render()

cn flag

I am trying to hide/remove the edit button on a view, for few records using the following code.

function member_management_views_pre_render(ViewExecutable $view) {
  if ($view->id() == 'my_view_id') {
    if (mycondition) {
      foreach($view->field as $key => $value) {
        // $value->_entity->operations->setValue() = 0;
        // operations->field->handlers->displayhandlers
      }
    }
  }
}
apaderno avatar
us flag
Welcome to Drupal Answers! The question just says what you want to achieve, but not what problem you exactly have, or what you exactly don't understand in achieving the described task. The pseudo-code shown in the question doesn't help much in understand that either.
R Potharaju avatar
cn flag
I have no clue on how to do it so. I was trying different ways. in views table. I have operations column which has edit button, I want to hide it for some records. but I can remove the complete column by $fields = $view->display_handler->getOption('fields'); $view->field['FIELD_NAME']->options['exclude'] = TRUE; instead I want o hide/remove the button for few records
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.