0

I have succesfully changed the search button text of the block but can't seem to get to do this on the search page

on the following form_alter both forms enter it and are set but only search_block_form gets affected

function MODULE_NAME_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if(in_array($form_id,["search_block_form","search_form"])) {
    $form['actions']['submit']['#value'] = "Custom Search Value";
  }
}

I have also tried doing it with function hook_preprocess_input($vars){ and also tried to set the weight of the module to run later than others

function MODULE_NAME_install(){
  module_set_weight('MODULE_NAME', 1000);
}

but I see no difference I had to resolve this using javascript what am I doing wrong ?

0

Did not realize the search page is structured different than a block search here is the solution that worked posting for anyone might have the same problem

function MODULE_NAME_form_alter(&$form, \Drupal\Core\Form\FormStateInterface $form_state, $form_id) {
  if(in_array($form_id,["search_block_form"])) {
    $form['actions']['submit']['#value'] = "Custom Search Value";
  }
  elseif(in_array($form_id,["search_form"])) {
    $form['basic']['submit']['#value'] = "Custom Search Value";
  }
}

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.