public function SaveSearch::blockForm in Search API Saved Searches 8
Overrides BlockPluginTrait::blockForm
File
- src/
Plugin/ Block/ SaveSearch.php, line 175
Class
- SaveSearch
- Displays the "Save search" form in a block.
Namespace
Drupal\search_api_saved_searches\Plugin\BlockCode
public function blockForm($form, FormStateInterface $form_state) {
$types = $this
->getEntityTypeManager()
->getStorage('search_api_saved_search_type')
->loadMultiple();
$type_options = [];
foreach ($types as $type_id => $type) {
$type_options[$type_id] = $type
->label();
}
$form['type'] = [
'#type' => 'select',
'#title' => $this
->t('Saved search type'),
'#description' => $this
->t('The type/bundle of saved searches that should be created by this block.'),
'#options' => $type_options,
'#default_value' => $this->configuration['type'] ?: key($type_options),
'#required' => TRUE,
];
return $form;
}