function SearchBlock::blockForm
Same name in other branches
- 9 core/modules/search/src/Plugin/Block/SearchBlock.php \Drupal\search\Plugin\Block\SearchBlock::blockForm()
- 8.9.x core/modules/search/src/Plugin/Block/SearchBlock.php \Drupal\search\Plugin\Block\SearchBlock::blockForm()
- 11.x core/modules/search/src/Plugin/Block/SearchBlock.php \Drupal\search\Plugin\Block\SearchBlock::blockForm()
Overrides BlockPluginTrait::blockForm
File
-
core/
modules/ search/ src/ Plugin/ Block/ SearchBlock.php, line 98
Class
- SearchBlock
- Provides a 'Search form' block.
Namespace
Drupal\search\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
// The configuration for this block is which search page to connect the
// form to. Options are all configured/active search pages.
$options = [];
$active_search_pages = $this->searchPageRepository
->getActiveSearchPages();
foreach ($this->searchPageRepository
->sortSearchPages($active_search_pages) as $entity_id => $entity) {
$options[$entity_id] = $entity->label();
}
$form['page_id'] = [
'#type' => 'select',
'#title' => $this->t('Search page'),
'#description' => $this->t('The search page that the form submits to, or Default for the default search page.'),
'#default_value' => $this->configuration['page_id'],
'#options' => $options,
'#empty_option' => $this->t('Default'),
'#empty_value' => '',
];
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.