You are here

public function BlockBase::buildConfigurationForm in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/lib/Drupal/Core/Block/BlockBase.php \Drupal\Core\Block\BlockBase::buildConfigurationForm()

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 PluginFormInterface::buildConfigurationForm

See also

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

1 call to BlockBase::buildConfigurationForm()
ViewsBlockBase::buildConfigurationForm in core/modules/views/src/Plugin/Block/ViewsBlockBase.php
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.
1 method overrides BlockBase::buildConfigurationForm()
ViewsBlockBase::buildConfigurationForm in core/modules/views/src/Plugin/Block/ViewsBlockBase.php
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.

File

core/lib/Drupal/Core/Block/BlockBase.php, line 155
Contains \Drupal\Core\Block\BlockBase.

Class

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

Namespace

Drupal\Core\Block

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $definition = $this
    ->getPluginDefinition();
  $form['provider'] = array(
    '#type' => 'value',
    '#value' => $definition['provider'],
  );
  $form['admin_label'] = array(
    '#type' => 'item',
    '#title' => $this
      ->t('Block description'),
    '#plain_text' => $definition['admin_label'],
  );
  $form['label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Title'),
    '#maxlength' => 255,
    '#default_value' => $this
      ->label(),
    '#required' => TRUE,
  );
  $form['label_display'] = array(
    '#type' => 'checkbox',
    '#title' => $this
      ->t('Display title'),
    '#default_value' => $this->configuration['label_display'] === BlockInterface::BLOCK_LABEL_VISIBLE,
    '#return_value' => BlockInterface::BLOCK_LABEL_VISIBLE,
  );

  // Add context mapping UI form elements.
  $contexts = $form_state
    ->getTemporaryValue('gathered_contexts') ?: [];
  $form['context_mapping'] = $this
    ->addContextAssignmentElement($this, $contexts);

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