Issue #2937636 by piyuesh23, markconroy: Umami Theme - follow-up - Use hook_form_alter() for search block placeholder

merge-requests/1654/head
Nathaniel Catchpole 2018-01-22 09:39:49 +00:00
parent 222377929b
commit 42c9e7bbd0
2 changed files with 8 additions and 18 deletions

View File

@ -1,18 +0,0 @@
{#
/**
* @file
* Theme override for an 'input' #type form element.
*
* Available variables:
* - attributes: A list of HTML attributes for the input element.
* - children: Optional additional rendered elements.
*
* @see template_preprocess_input()
*/
#}
{%
set placeholder_text = 'Search by keyword, ingredient, dish'
%}
<input{{ attributes.setAttribute('placeholder', placeholder_text) }} />{{ children }}

View File

@ -5,6 +5,7 @@
* Functions to support theming in the Umami theme.
*/
use Drupal\Core\Form\FormStateInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
/**
@ -81,3 +82,10 @@ function umami_preprocess_breadcrumb(&$variables) {
// "Home > Articles" on the Recipes page, which should read "Home > Recipes".
$variables['#cache']['contexts'][] = 'url';
}
/**
* Implements hook_form_FORM_ID_alter().
*/
function umami_form_search_block_form_alter(&$form, FormStateInterface $form_state) {
$form['keys']['#attributes']['placeholder'] = t('Search by keyword, ingredient, dish');
}