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.
I'm attempting to change the placeholder text for the origin field in the proximity filter. Here is what I have so far - it just doesn't seem to be doing the job. What is the obvious thing I am missing?
if($form_id == 'views_exposed_form') {
$view = $form_state['view'];
if ($view->name == 'omapx' && $view->current_display == 'page_3') {
$form['field_geofield_distance_origin']['#attributes']['placeholder'] = t('Missoula, MT');
}
}
Comments
Comment #1
bisonbleu CreditAttribution: bisonbleu commented@stopshinal, did you find a solution?
I also would like to set a placeholder text in the proximity search field e.g. "Enter zip code or street address here...".
Any suggestions on how best to do this?
Comment #2
bisonbleu CreditAttribution: bisonbleu commentedBetter title (I hope).
Comment #3
tpaddy CreditAttribution: tpaddy commentedI created a small custom module and used the following code to add placeholder text. This is the comment that helped me figure out how to modify the exposed filter form
Hope that helps!
Comment #4
quercus020 CreditAttribution: quercus020 commentedThis works a treat. Thanks for posting.
Comment #5
malcomio CreditAttribution: malcomio commentedYes - works great. In case anyone else is dopey like me and misses it, the process function does not pass $element by reference, so you need to have the return $element line at the end.
Comment #7
RumpledElf CreditAttribution: RumpledElf commentedYou can also do this: