You are here

public function ExampleConfigurableTextBlock::blockForm in Examples for Developers 8

Same name and namespace in other branches
  1. 3.x modules/block_example/src/Plugin/Block/ExampleConfigurableTextBlock.php \Drupal\block_example\Plugin\Block\ExampleConfigurableTextBlock::blockForm()

This method defines form elements for custom block configuration. Standard block configuration fields are added by BlockBase::buildConfigurationForm() (block title and title visibility) and BlockFormController::form() (block visibility settings).

Overrides BlockPluginTrait::blockForm

See also

\Drupal\block\BlockBase::buildConfigurationForm()

\Drupal\block\BlockFormController::form()

File

block_example/src/Plugin/Block/ExampleConfigurableTextBlock.php, line 50

Class

ExampleConfigurableTextBlock
Provides a 'Example: configurable text string' block.

Namespace

Drupal\block_example\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $form['block_example_string_text'] = [
    '#type' => 'textarea',
    '#title' => $this
      ->t('Block contents'),
    '#description' => $this
      ->t('This text will appear in the example block.'),
    '#default_value' => $this->configuration['block_example_string'],
  ];
  return $form;
}