You are here

public function SiteAlertBlock::buildConfigurationForm in Site Alert 8

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

See also

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

File

src/Plugin/Block/SiteAlertBlock.php, line 176

Class

SiteAlertBlock
Implements SiteAlertBlock class.

Namespace

Drupal\site_alert\Plugin\Block

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  $form = parent::buildConfigurationForm($form, $form_state);
  $timeout = $this
    ->getConfiguration()['timeout'];
  $form['timeout'] = [
    '#type' => 'number',
    '#title' => $this
      ->t('Timeout'),
    '#description' => $this
      ->t('After how many seconds the alerts should be refreshed. Set to 0 if you do not wish to poll the server for updates.'),
    '#default_value' => $timeout,
    '#field_suffix' => ' ' . $this
      ->t('seconds'),
    '#required' => TRUE,
    '#min' => 0,
  ];
  return $form;
}