public function CustomBlockBlock::blockForm

Overrides \Drupal\block\BlockBase::blockForm().

Adds body and description fields to the block configuration form.

Overrides BlockBase::blockForm

File

drupal/core/modules/block/custom_block/lib/Drupal/custom_block/Plugin/Block/CustomBlockBlock.php, line 42
Contains \Drupal\custom_block\Plugin\Block\CustomBlockBlock.

Class

CustomBlockBlock
Defines a generic custom block type.

Namespace

Drupal\custom_block\Plugin\Block

Code

public function blockForm($form, &$form_state) {
  $options = array();
  $view_modes = entity_get_view_modes('custom_block');
  foreach ($view_modes as $view_mode => $detail) {
    $options[$view_mode] = $detail['label'];
  }
  $form['custom_block']['view_mode'] = array(
    '#type' => 'select',
    '#options' => $options,
    '#title' => t('View mode'),
    '#description' => t('Output the block in this view mode.'),
    '#default_value' => $this->configuration['view_mode'],
  );
  $form['title']['#description'] = t('The title of the block as shown to the user.');
  return $form;
}