0

I'm using a sub-theme of the Bootstrap v8.x-3.1 theme.

By default the search button shows the search icon.

In the theme settings you can un-check 'Iconize Buttons' which I expect would show the 'Search' text instead of the icon, however it shows an empty button... no text or icon.

Iconize Buttons

How do I get the button to show 'Search' text instead of an icon?

1

The solution I found for this was to copy this file from the Bootstrap theme directory

src/Plugin/Form/SearchBlockForm.php

to the same location in your sub-theme.

Then you can set the icon_only property to FALSE.

e.g.

<?php
/**
 * @file
 * Contains \Drupal\subtheme\Plugin\Form\SearchBlockForm.
 */

namespace Drupal\subtheme\Plugin\Form;

use Drupal\bootstrap\Annotation\BootstrapForm;
use Drupal\bootstrap\Plugin\Form\FormBase;
use Drupal\bootstrap\Utility\Element;
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_form_FORM_ID_alter().
 *
 * @ingroup plugins_form
 *
 * @BootstrapForm("search_block_form")
 */
class SearchBlockForm extends FormBase {

  /**
   * {@inheritdoc}
   */
  public function alterFormElement(Element $form, FormStateInterface $form_state, $form_id = NULL) {
    $form->actions->submit->setProperty('icon_only', FALSE);
    $form->keys->setProperty('input_group_button', FALSE);
  }

}

I still think there must be an easier way... but until then.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.