You are here

public function SearchApiPageBlock::blockForm in Search API Pages 8

Overrides BlockPluginTrait::blockForm

File

src/Plugin/Block/SearchApiPageBlock.php, line 85

Class

SearchApiPageBlock
Provides a 'Search Api page form' block.

Namespace

Drupal\search_api_page\Plugin\Block

Code

public function blockForm($form, FormStateInterface $form_state) {
  $options = [];
  $search_api_pages = $this->searchApiPageStorage
    ->loadMultiple();
  foreach ($search_api_pages as $search_api_page) {
    $options[$search_api_page
      ->id()] = $search_api_page
      ->label();
  }
  $form['search_api_page'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Search page'),
    '#default_value' => !empty($this->configuration['search_api_page']) ? $this->configuration['search_api_page'] : '',
    '#description' => $this
      ->t('Select to which search page a submission of this form will redirect to'),
    '#options' => $options,
    '#required' => TRUE,
  ];
  return $form;
}