I have an entity with entitylisthandler.

In entitylisthandler, i have a function to build row like:

public function buildRow(EntityInterface $entity) {

    /* @var $entity \Drupal\mymodule\Entity\xyz*/
    $row['id'] = $entity->id();
    $row['config_name'] = $entity->link();
    //$row['first_name'] = $entity->first_name->value;
    $row['ctype'] = $entity->ctype->value;
    return $row + parent::buildRow($entity);

In @line 3:

$row['config_name'] = $entity->link();

I'm calling link function here which calls entity canonical link.

How to change this default value 'canonical' to some other link like 'delete-form'?

This is the Drupal core link function which I'm trying to override in entitylistbuilder file.

public function link($text = NULL, $rel = 'delete-form', array $options = []) {
  return $this->toLink($text, $rel, $options)->toString();

I have changed its argument from 'canonical' to 'delete-form', but it won't work.

1 Answer 1


You should not change the core function. What core does, if $rel is not set, it uses 'canonical'. If you want to use 'delete-form' instead, put this as an argument when using the link function:

$row['config_name'] = $entity->link(NULL, 'delete-form');

BTW, link() is deprecated, so use toLink() instead.

Your Answer

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

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