Drupal Answers Asked by Tritof on January 6, 2022
So far I have tried this code in mytheme.theme:
function mytheme_form_search_block_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
$form['keys']['#attributes']['placeholder'] = t('Custom wording');
}
And this one:
function mytheme_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
if ($form_id == 'search_block_form') {
$form['keys']['#attributes']['placeholder'] = t('Custom wording');
}
}
Also this one:
function mytheme_form_search_block_form_alter(&$form, $form_state) {
$form['keys']['#attributes']['placeholder'] = t('Custom wording');
}
Site is not crashing, but nothing happens on the placeholder.
I have based these 3 snippets on these pages:
This code should create the placeholder:
function mytheme_form_search_block_form_alter(&$form, DrupalCoreFormFormStateInterface $form_state, $form_id) {
$form['keys']['#attributes']['placeholder'] = t('The new placeholder');
}
So if that does not work for you, it might be because you need to clear the cache.
Answered by user72672 on January 6, 2022
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP