Question:
How to change the class on the submit button on the search block form?
We can use the hook_form_alter() function. You can place it within your theme.theme file or in your custom module.
/** * Implementation of hook_form_alter() * To: change the class on the submit button on the search_block_form from 'btn-primary' to 'btn-secondary' */ function {mythemename}_form_alter(&$form, &$form_state, $form_id) { if ($form_id == 'search_block_form') { $form['actions']['submit']['#attributes']['class'][] = 'btn-secondary'; } }
If you want to print out the variables you can as below or the Devel module.
function {mythemename}_form_alter(&$form, &$form_state, $form_id) { print_r($form_id); if ($form_id == 'search_block_form') { dump($form); $form['actions']['submit']['#attributes']['class'][] = 'btn-light'; dump($form); } }
The screenshot below highlights the class 'btn-secondary' has been added.
Image:

Drupal version: