Score:0

How do I alter a view and add/change the form action in Entity View Attachment (eva) with table format?

cn flag

I have 2 related content types (Order and Proposals). In the Order Detail page, I attach the proposals for that order using EVA with table format.

screenshot

I want to add an action button (vote) in EVA output (orange colored box buttons), so that when it's clicked, it updates the Vote field in the corresponding proposal node. I don't know where to start.

I've tried using hook_view_pre_render() but I can't find the corresponding object because the dpm() breaks the site.

This is the code I am using.

function mymodule_views_pre_render(\Drupal\views\ViewExecutable $view) {
  if ($view->id() == 'order_proposal_list') {
    $results = $view->result;
    dpm($view); // This breaks the site.
    ddm($view); // This outputs 300000 and more lines in drupal_debug.txt.
  }
}

Somehow, I can get that field value using this code, but it's still not enough.

function mymodule_preprocess_views_view_field(&$variables)  {
  $view = $variables['view'];
  if ($view->id() == 'order_quotation_list') {
    if ($variables['field']->field == 'edit_node') {
      dpm($variables['output']);
    }
  }
}
Score:0
cn flag

It's too late to change field plugins at this stage. You have to configure them in the View.

You could create a custom field handler plugin providing the button link and make it available in Views via hook_views_data().

On a higher level of the Entity API entities define operations. You can add your own in hook_entity_operation() or alter them in the corresponding alter hook. To use them in a View add the field Operation Links. The existing core operations edit/delete are only displayed for users who have access.

On a lower level, directly adding the HTML markup of the button to the field, use the rewrite input box of the Views field UI. See How can I theme individual fields in a row?

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.