You are here

public function TestInlineTemplateFormBlock::build in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestInlineTemplateFormBlock.php \Drupal\layout_builder_form_block_test\Plugin\Block\TestInlineTemplateFormBlock::build()

Builds and returns the renderable array for this block plugin.

If a block should not be rendered because it has no content, then this method must also ensure to return no content: it must then only return an empty array, or an empty array with #cache set (with cacheability metadata indicating the circumstances for it being empty).

Return value

array A renderable array representing the content of the block.

Overrides BlockPluginInterface::build

See also

\Drupal\block\BlockViewBuilder

File

core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestInlineTemplateFormBlock.php, line 23

Class

TestInlineTemplateFormBlock
Provides a block containing inline template with <form> tag.

Namespace

Drupal\layout_builder_form_block_test\Plugin\Block

Code

public function build() {
  $build['form'] = [
    '#type' => 'inline_template',
    '#template' => '<form method="POST"><label>{{ "Keywords"|t }}<input name="keyword" type="text" required /></label><input name="submit" type="submit" value="{{ "Submit"|t }}" /></form>',
  ];
  return $build;
}