function panopoly_search_form_views_exposed_form_alter in Panopoly Search 8.2
Implements hook_form_FORM_ID_alter().
File
- ./
panopoly_search.module, line 81 - Hooks for the panopoly_search module.
Code
function panopoly_search_form_views_exposed_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\views\Entity\View $view */
$view = $form_state
->getStorage('view')['view'];
if (in_array($view
->id(), [
'panopoly_search_db',
'panopoly_search_solr',
])) {
$form['keys']['#title'] = t('Enter your keywords');
$form['keys']['#type'] = 'search';
// Use the default styling from theme.
$form['#attributes']['class'][] = 'search-form';
// This one is specifically for Bartik.
$form['actions']['submit']['#attributes']['class'][] = 'search-form__submit';
// Wrap the keys and button in an inline container.
$form['container'] = [
'#type' => 'container',
'#attributes' => [
'class' => [
'container-inline',
],
],
];
foreach ([
'keys',
'actions',
] as $key) {
$form['container'][$key] = $form[$key];
unset($form[$key]);
}
$form['#attributes']['class'][] = 'clearfix';
// Add a validation callback.
$form['#validate'][] = '_panopoly_search_form_validate';
}
}