function TestFormApiFormBlock::buildForm

Same name in other branches
  1. 9 core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestFormApiFormBlock.php \Drupal\layout_builder_form_block_test\Plugin\Block\TestFormApiFormBlock::buildForm()
  2. 10 core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestFormApiFormBlock.php \Drupal\layout_builder_form_block_test\Plugin\Block\TestFormApiFormBlock::buildForm()
  3. 11.x core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestFormApiFormBlock.php \Drupal\layout_builder_form_block_test\Plugin\Block\TestFormApiFormBlock::buildForm()

Overrides FormInterface::buildForm

File

core/modules/layout_builder/tests/modules/layout_builder_form_block_test/src/Plugin/Block/TestFormApiFormBlock.php, line 78

Class

TestFormApiFormBlock
Provides a block containing a Form API form for use in Layout Builder tests.

Namespace

Drupal\layout_builder_form_block_test\Plugin\Block

Code

public function buildForm(array $form, FormStateInterface $form_state) {
    $form['keywords'] = [
        '#title' => $this->t('Keywords'),
        '#type' => 'textfield',
        '#attributes' => [
            'placeholder' => $this->t('Keywords'),
        ],
        '#required' => TRUE,
        '#title_display' => 'invisible',
        '#weight' => 1,
    ];
    $form['actions'] = [
        '#type' => 'actions',
        'submit' => [
            '#name' => '',
            '#type' => 'submit',
            '#value' => $this->t('Search'),
        ],
        '#weight' => 2,
    ];
    return $form;
}

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