function LayoutBuilderEntityFormTrait::buildMessageContainer

Same name in other branches
  1. 10 core/modules/layout_builder/src/Form/LayoutBuilderEntityFormTrait.php \Drupal\layout_builder\Form\LayoutBuilderEntityFormTrait::buildMessageContainer()

Build the message container.

Parameters

\Drupal\Core\StringTranslation\TranslatableMarkup $message: The message to display.

string $type: The form type this is being attached to.

Return value

array The render array.

2 calls to LayoutBuilderEntityFormTrait::buildMessageContainer()
DefaultsEntityForm::buildMessage in core/modules/layout_builder/src/Form/DefaultsEntityForm.php
Renders a message to display at the top of the layout builder.
OverridesEntityForm::buildMessage in core/modules/layout_builder/src/Form/OverridesEntityForm.php
Renders a message to display at the top of the layout builder.

File

core/modules/layout_builder/src/Form/LayoutBuilderEntityFormTrait.php, line 34

Class

LayoutBuilderEntityFormTrait
Provides a trait for common methods used in Layout Builder entity forms.

Namespace

Drupal\layout_builder\Form

Code

protected function buildMessageContainer(TranslatableMarkup $message, string $type) : array {
    return [
        '#type' => 'container',
        '#attributes' => [
            'class' => [
                'layout-builder__message',
                sprintf('layout-builder__message--%s', $type),
            ],
        ],
        'message' => [
            '#theme' => 'status_messages',
            '#message_list' => [
                'status' => [
                    $message,
                ],
            ],
            '#status_headings' => [
                'status' => $this->t('Status message'),
            ],
        ],
        '#weight' => -900,
    ];
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.