When creating a new node, you can assign it a group (group project). I need the group field's value to put into my node title.

The problem is, there is no token to use within AEL for the group and even with the following code (using php code inside AEL):

use Drupal\group\Entity\GroupContent;

function getGroupIdsByEntity($entity) {
  $group_ids = [];

  $group_contents = GroupContent::loadByEntity($entity);
  foreach ($group_contents as $group_content) {
    $group_ids[] = $group_content->getGroup()->id();

  return $group_ids;

you get the error that groups cannot be loaded for unsaved entities (maybe thats why there is no token...).

Now, is there a way to get the group using AEL or do I have to alter the node create form submit before the node is saved, get the id of the selected group and so on?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.