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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.