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
\Drupal\block\BlockBase::blockForm()
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;
}