0

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']);
    }
  }
}

1 Answer 1

0

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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.