You are here

public function BlockContentBlock::blockForm in Zircon Profile 8

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

Overrides BlockBase::blockForm

File

core/modules/block_content/src/Plugin/Block/BlockContentBlock.php, line 125
Contains \Drupal\block_content\Plugin\Block\BlockContentBlock.

Class

BlockContentBlock
Defines a generic custom block type.

Namespace

Drupal\block_content\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $uuid = $this
    ->getDerivativeId();
  $block = $this->entityManager
    ->loadEntityByUuid('block_content', $uuid);
  $options = $this->entityManager
    ->getViewModeOptionsByBundle('block_content', $block
    ->bundle());
  $form['view_mode'] = array(
    '#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;
}