You are here

public function LiveWeatherBlock::blockForm in Live Weather 8.2

Same name and namespace in other branches
  1. 8 src/Plugin/Block/LiveWeatherBlock.php \Drupal\live_weather\Plugin\Block\LiveWeatherBlock::blockForm()

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/LiveWeatherBlock.php, line 71
Contains \Drupal\live_weather\Plugin\Block\LiveWeatherBlock.

Class

LiveWeatherBlock
Provides a 'Live Weather' block.

Namespace

Drupal\live_weather\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $location_list = $this->configFactory
    ->get('live_weather.location')
    ->get('location');
  $default = array_keys($location_list);
  if (isset($this->configuration['list']['list'])) {
    $default = array_values($this->configuration['list']['list']);
  }
  $form['location'] = array(
    '#type' => 'details',
    '#title' => $this
      ->t('Location list'),
    '#collapsible' => FALSE,
    '#collapsed' => FALSE,
  );
  $form['location']['list'] = array(
    '#type' => 'checkboxes',
    '#multiple' => TRUE,
    '#options' => $location_list,
    '#default_value' => $default,
    '#description' => $this
      ->t('Select locations to display in block'),
  );
  return $form;
}