You are here

public function BlockContentBlock::blockForm in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/block_content/src/Plugin/Block/BlockContentBlock.php \Drupal\block_content\Plugin\Block\BlockContentBlock::blockForm()
  2. 9 core/modules/block_content/src/Plugin/Block/BlockContentBlock.php \Drupal\block_content\Plugin\Block\BlockContentBlock::blockForm()

Overrides \Drupal\Core\Block\BlockBase::blockForm().

Adds body and description fields to the block configuration form.

File

core/modules/block_content/src/Plugin/Block/BlockContentBlock.php, line 144

Class

BlockContentBlock
Defines a generic custom block type.

Namespace

Drupal\block_content\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $block = $this
    ->getEntity();
  if (!$block) {
    return $form;
  }
  $options = $this->entityDisplayRepository
    ->getViewModeOptionsByBundle('block_content', $block
    ->bundle());
  $form['view_mode'] = [
    '#type' => 'select',
    '#options' => $options,
    '#title' => $this
      ->t('View mode'),
    '#description' => $this
      ->t('Output the block in this view mode.'),
    '#default_value' => $this->configuration['view_mode'],
    '#access' => count($options) > 1,
  ];
  $form['title']['#description'] = $this
    ->t('The title of the block as shown to the user.');
  return $form;
}