3

I notice in Drupal source code, in core modules hook_theme(), some places are 'render element' => 'element' and some places are 'render element' => 'elements' (plural). Why? Even the render element purpose is to display a single object (e.g. node canonical), not a list of objects.

The problem is it results in different key in $variables in template_preprocess_hook(). For instance, I have a custom entity and if I use _entity_view in entity canonical route, the $variables has 'elements'. But if I manually use this entity theme in a page, the $variables has 'element'. I'm so confused.

1 Answer 1

0

Because it wasn't standardized.

The safe approach is to check the info array for the render element key.

There is actually an issue with the field groups module that ignores everything but form & elements.

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.