function olivero_form_alter
Same name in other branches
- 9 core/themes/olivero/olivero.theme \olivero_form_alter()
- 10 core/themes/olivero/olivero.theme \olivero_form_alter()
Implements hook_form_alter() for adding classes and placeholder text to the search forms.
File
-
core/
themes/ olivero/ olivero.theme, line 195
Code
function olivero_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (isset($form['actions']['submit']) && count($form['actions']) <= 2) {
$form['actions']['submit']['#attributes']['class'][] = 'button--primary';
}
switch ($form_id) {
case 'search_block_form':
// Add placeholder text to keys input.
$form['keys']['#attributes']['placeholder'] = t('Search by keyword or phrase.');
// Add classes to the search form submit input.
$form['actions']['submit']['#attributes']['class'][] = 'search-form__submit';
break;
case 'search_form':
$form['basic']['keys']['#attributes']['placeholder'] = t('Search by keyword or phrase.');
$form['basic']['submit']['#attributes']['class'][] = 'button--primary';
$form['advanced']['submit']['#attributes']['class'][] = 'button--primary';
break;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.