public function BlockBase::form

Implements \Drupal\block\BlockPluginInterface::form().

Creates a generic configuration form for all block types. Individual block plugins can add elements to this form by overriding BlockBase::blockForm(). Most block plugins should not override this method unless they need to alter the generic form elements.

Overrides BlockPluginInterface::form

See also

\Drupal\block\BlockBase::blockForm()

1 call to BlockBase::form()
ViewsBlock::form in drupal/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
Overrides \Drupal\block\BlockBase::form().
1 method overrides BlockBase::form()
ViewsBlock::form in drupal/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php
Overrides \Drupal\block\BlockBase::form().

File

drupal/core/modules/block/lib/Drupal/block/BlockBase.php, line 113
Contains \Drupal\block\BlockBase.

Class

BlockBase
Defines a base block implementation that most blocks plugins will extend.

Namespace

Drupal\block

Code

public function form($form, &$form_state) {
  $definition = $this
    ->getPluginDefinition();
  $form['module'] = array(
    '#type' => 'value',
    '#value' => $definition['module'],
  );
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#maxlength' => 255,
    '#default_value' => !empty($this->configuration['label']) ? $this->configuration['label'] : $definition['admin_label'],
    '#required' => TRUE,
  );
  $form['label_display'] = array(
    '#type' => 'checkbox',
    '#title' => t('Display title'),
    '#default_value' => $this->configuration['label_display'] == BLOCK_LABEL_VISIBLE,
    '#return_value' => BLOCK_LABEL_VISIBLE,
  );

  // Add plugin-specific settings for this block type.
  $form += $this
    ->blockForm($form, $form_state);
  return $form;
}