You are here

public function CalendarLegend::blockForm in Calendar 8

Returns the configuration form elements specific to this block plugin.

Blocks that need to add form elements to the normal block configuration form should implement this method.

Parameters

array $form: The form definition array for the block configuration form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The renderable form array representing the entire configuration form.

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/CalendarLegend.php, line 23

Class

CalendarLegend
Provides a "Calendar legend" block.

Namespace

Drupal\calendar\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $options = CalendarHelper::listCalendarViews();
  $config = $this
    ->getConfiguration();
  $form['calendar_legend_view'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Legend View'),
    '#description' => $this
      ->t('Choose the view display that contains the settings for the stripes that should be displayed in a legend in this block. Note that if you change the stripe values in that view you will need to clear the cache to pick up the new values in this block.'),
    '#default_value' => isset($config['calendar_legend_view_settings_view']) ? $config['calendar_legend_view_settings_view'] : '',
    '#options' => $options,
  ];
  return $form;
}