Render Arrays

Render arrays contain data to be rendered and instructions on how to display it.

This render array prints a text string.

$output = [
  '#markup' => 'Hello world!';
];

Render array properties

Properties start with # and define the structure of the component to render.

Preprocessing

You can preprocess render array, or interrupt and modify their display.

Find render elements

When working on render arrays, it can be difficult to tell what you can use.

You can find core's form and render elements in the api: https://api.drupal.org/api/drupal/elements

To find all render elements available in your codebase, use your IDE to look for classes that extend RenderElement.

Topics