.theme file not being reached by all hooks and preprocessing not implemented

68 views Asked by At

So i am tryin got implement a theme in drupal 8, I wanted to eliminate the search button from the search form. But when I attempt to use hook_form_alter nothing in my .theme file is being reached and I cant think of a reason as far as I can tell all my syntax is correct. Even if it isn't correct the 'die' and var_dump statements at minimum should output something but currently are not.

I have changed the default theme to the drupal8_zymphonies_theme and the hooks are engaged on that theme so I figure there must be some kind of setting that need schanging. That being said the zymphonies theme is in this structure /theme/drupa8_zymphonies_theme while my endymion theme is theme/custom/endymion. Not sure if that matters but i though that i would mention it.

/**
 * @file
 * Contains theme override functions and preprocess functions
 */
var_dump('another hello');
die('hello there');
use Drupal\Core\Template\RenderWrapper;
use Drupal\search\Form\SearchBlockForm;
use Drupal\Core\Form\FormStateInterface;

    function endymion_form_search_block_form_alter(SearchBlockForm &$form, FormStateInterface &$form_state, $form_id) {
  //Remove the search box from the form to make the look a little cleaner
  $logger = \Drupal::logger('endymion');
  $logger->debug(''. print_R($form, true) . 'search form');
  if ($form_id == 'search_block_form') {
    $logger->debug(''. print_R($form, true) . 'search form');
    $form['actions']['#attributes']['class'][] = 'element-invisible';

    $form['search_block_form']['#size'] = 40;  // define size of the textfield
    $form['search_block_form']['#default_value'] = t('Search'); // Set a default value for the textfield

    // Add extra attributes to the text box
    $form['search_block_form']['#attributes']['onblur'] = "if (this.value == '') {this.value = 'Search';}";
    $form['search_block_form']['#attributes']['onfocus'] = "if (this.value == 'Search') {this.value = '';}";
    // Prevent user from searching the default text
    $form['#attributes']['onsubmit'] = "if(this.search_block_form.value=='Search'){ alert('Please enter a search'); return false; }";

    // Alternative (HTML5) placeholder attribute instead of using the javascript
    $form['search_block_form']['#attributes']['placeholder'] = t('Search');
  }
}
0

There are 0 answers