Reported in https://www.drupal.org/project/drupal/issues/2809635#comment-12432197

We have a template input--search.html.twig to add a placeholder. @larowlan suggested this could be a form_alter.

from issue:
=============
+++ b/core/profiles/demo_umami/themes/umami/templates/components/search/input--search.html.twig
@@ -0,0 +1,18 @@
+ set placeholder_text = 'Search by keyword, ingredient, dish'
+%}
+
+{{ children }}

Are we sure doing this globally for the search element is the best option?

Suggest a form_alter in the theme instead and then dropping this template?
=============

Looking at the code, I agree. I don't think what we have in the template is translatable, so we can wrap it in a t('') string in a form_alter.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

markconroy created an issue. See original summary.

piyuesh23’s picture

Moved Placeholder inside form alter in umami.theme. Uploading the patch here. Also, updating the version number to 8.6.x-dev here, since the profile is committed to 8.6.x now.

piyuesh23’s picture

Status: Active » Needs review
markconroy’s picture

Status: Needs review » Reviewed & tested by the community

Thanks a lot @piyuesh23. Looks ready to be committed.

markconroy’s picture

Component: profile.module » Umami demo
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 42c9e7b and pushed to 8.6.x. Thanks!

  • catch committed 42c9e7b on 8.6.x
    Issue #2937636 by piyuesh23, markconroy: Umami Theme - follow-up - Use...
thamas’s picture

Hm, I just do not understand this issue. We worked a lot to make Drupal theming more understandable for non php developers. One thing was to reach this goal to move as much as possible to templates instead of keeping them in php code.

Such a simple thing as creating a variable does not need any form_alter IMHO.

(Missing possibilty of translation in the above code is valid but that can be solved easily in the template too.)

David_Rothstein’s picture

Well, this shouldn't really be a theming task to begin with - ideally it would be more of a site configuration task anyway. I reopened this very old Search module issue now for discussion: #760182: Add configurable placeholder text to search box that goes away when the box is clicked

  • alexpott committed 7eaad71 on 8.5.x authored by catch
    Issue #2937636 by piyuesh23, markconroy: Umami Theme - follow-up - Use...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.