TestInlineTemplateFormBlock.php

Same filename and directory in other branches
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestInlineTemplateFormBlock.php
  2. 10 core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestInlineTemplateFormBlock.php
  3. 11.x core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestInlineTemplateFormBlock.php

Namespace

Drupal\layout_builder_form_block_test\Plugin\Block

File

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

View source
<?php

namespace Drupal\layout_builder_form_block_test\Plugin\Block;

use Drupal\Core\Block\BlockBase;

/**
 * Provides a block containing inline template with <form> tag.
 *
 * For use in Layout Builder tests.
 *
 * @Block(
 *   id = "layout_builder_form_block_test_inline_template_form_block",
 *   admin_label = @Translation("Layout Builder form block test inline template form block"),
 *   category = @Translation("Layout Builder form block test")
 * )
 */
class TestInlineTemplateFormBlock extends BlockBase {
    
    /**
     * {@inheritdoc}
     */
    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;
    }

}

Classes

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

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