2

Is there any way to add a specific action button in view module for an entity I've created programmatically.

More specifically, I want to make a search of my entity in view, and having beside each result of the entity an action button . Currently, we can configure 'delete/edit' button. I want to add a specific one.

PS: I'm using Drupal 8 and i created my module an entity with drupal console.

2
  • What is this button will do?
    – pierostz
    Aug 29, 2016 at 11:49
  • it will increment the value of a field in the entity row concerned
    – Asy
    Aug 29, 2016 at 11:53

1 Answer 1

2

Here is the solution I found for my problem: Let say that my entity is named Entity. I created a new operation in my controller implementing my business logic , say we'll call it operation_name. Then, in my EntityListBuilder.php , I surcharged the operation getDefaultOperations, specifying the name of my operation, the url and title : public function getDefaultOperations(EntityInterface $entity) { $operations = parent::getDefaultOperations($entity); $operations['operation_name'] = array( 'title' => $this->t('operation_title'), 'weight' => 30, 'url' => new Url('url',array( 'medecin' => $entity->id(), ) ) ); return $operations; }

Back to my view configuration: In adding fields section I will add "Action link" , we will notice that the operation "operation_name" was add to the others (edit and delete).

1

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.