function opigno_search_block_form in Opigno Search 8
Same name and namespace in other branches
- 3.x opigno_search.module \opigno_search_block_form()
Get exposed filterers from search view.
File
- ./
opigno_search.module, line 15 - Contains opigno_search.module.
Code
function opigno_search_block_form() {
$view = Views::getView('search_content');
if (!empty($view)) {
$view
->initHandlers();
$form_state = new FormState();
$form_state
->setFormState([
'view' => $view,
'display' => [
'id' => 'page_1',
],
'exposed_form_plugin' => $view->display_handler
->getPlugin('exposed_form'),
'method' => 'get',
'rerender' => TRUE,
'no_redirect' => FALSE,
'always_process' => TRUE,
]);
$form = \Drupal::formBuilder()
->buildForm('Drupal\\views\\Form\\ViewsExposedForm', $form_state);
$form['#id'] = $form['#id'] . '_opigon';
if (isset($form['keys'])) {
$form['keys']['#title'] = t('Search keys');
}
$form['actions']['submit']['#value'] = t('Submit search keys');
return \Drupal::service('renderer')
->render($form);
}
else {
return 'Could not find view "Search Content"';
}
}