function TestAjaxBlock::blockForm

Same name in other branches
  1. 8.9.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAjaxBlock.php \Drupal\layout_builder_test\Plugin\Block\TestAjaxBlock::blockForm()
  2. 10 core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAjaxBlock.php \Drupal\layout_builder_test\Plugin\Block\TestAjaxBlock::blockForm()
  3. 11.x core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAjaxBlock.php \Drupal\layout_builder_test\Plugin\Block\TestAjaxBlock::blockForm()

Overrides BlockPluginTrait::blockForm

File

core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAjaxBlock.php, line 22

Class

TestAjaxBlock
Provides a 'TestAjax' block.

Namespace

Drupal\layout_builder_test\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
    $form['ajax_test'] = [
        '#type' => 'radios',
        '#options' => [
            1 => $this->t('Ajax test option 1'),
            2 => $this->t('Ajax test option 2'),
        ],
        '#prefix' => '<div id="test-ajax-wrapper">',
        '#suffix' => '</div>',
        '#title' => $this->t('Time in this ajax test is @time', [
            '@time' => time(),
        ]),
        '#ajax' => [
            'wrapper' => 'test-ajax-wrapper',
            'callback' => [
                $this,
                'ajaxCallback',
            ],
        ],
    ];
    return $form;
}

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