You are here

public function TestFormApiFormBlock::buildForm in Drupal 10

Same name and namespace in other branches
  1. 8 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. 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()

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

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;
}