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
1 Asked on January 6, 2022 by billyjoe
1 Asked on January 6, 2022 by bb2j3z
2 Asked on January 4, 2022 by philipp-michael
1 Asked on January 2, 2022 by cocoskin
1 Asked on January 2, 2022
1 Asked on January 2, 2022 by tyler-frankenstein
1 Asked on December 31, 2021 by toptomato
2 Asked on December 31, 2021 by drii7
1 Asked on December 31, 2021 by ashutoshsngh
0 Asked on December 31, 2021
1 Asked on December 31, 2021
1 Asked on December 28, 2021 by kevindeleon
1 Asked on December 28, 2021 by i-am-batman
1 Asked on December 28, 2021 by bapafe
Get help from others!
Recent Answers
Recent Questions
© 2023 AnswerBun.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP