Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Uses LESS starterkit to create sub-theme. All work well. But, can't customize search box form.
- Enable 'Display title' for block doesn't show the Label
- Overwrite Placeholder use mytheme_form_search_block_form_alter() doesn't work.
- Overwrite Placeholder use Translation module work. But it change all placeholder, label & submit value. It's weird they should have difference value.
Comment | File | Size | Author |
---|---|---|---|
#2 | 2884682-Search-box-form-cant-customized.patch | 524 bytes | Majdi |
Comments
Comment #2
Majdi CreditAttribution: Majdi commentedI can confirm the search block title visibility problem, that's because the CSS class .visually-hidden where added in the template file block--search-form-block.html.twig
I attach patch for that but i'm not sure if this how it should be
For the placeholder problem, could you please paste the code you are using to customize the form.
Comment #3
markhalliwellThe block title is hidden by default because the input field has the placeholder.
The placeholder code is located in https://drupal-bootstrap.org/api/bootstrap/src%21Plugin%21Process%21Sear...
Comment #4
glycid CreditAttribution: glycid as a volunteer commented@markcarver: Changing the placeholder value in Search.php has no effekt!
Where can I change the placeholder value?
Comment #5
nikathoneNot sure if this can be considered as right solution but for now in order to change the placeholder I also need to change the title attribute
I can remove
$form->keys->setAttribute('placeholder', $title);
from the code above but my placeholder will still work. Maybe this belongs in another issue as a bug...Comment #6
markhalliwellAs stated above, the block title is visually hidden since there is a placeholder in the textfield. If you don't like this, you can easily change this in your sub-theme.
The placeholder is created in Search::processElement.
In your sub-theme, you can either:
a) Sub-class this process method or
b) Create a new process method that runs after the base-theme's
In either case, this does work properly if configured properly.
Comment #7
sanu12345 CreditAttribution: sanu12345 commentedFind the search box with this form you don't need to customize anything just copy and paste the code...
Comment #8
devil2005 CreditAttribution: devil2005 commentedSame issue here... can't editing the placeholder... but anothers attributes are modified... i don't know why.
first and second lines are functional but third not...
Comment #9
devil2005 CreditAttribution: devil2005 commentedThis code works :