Field Template Suggestions: Target a particular field type on a content type I want to use a field template for all the fields on my &quot;journal_page&quot; content type that use a widget of &quot;long text&quot;.
How would I do this?
N.B.  My field is not named &quot;long text&quot;. &quot;Long text&quot; is the name of the widget I am using (It is a text field). I want to use the same template file for multiple differently named fields. The only thing they have in common is the widget type.

 Steps I have tried 
On Drupal Theming suggestions it says you must use the following format: field--[type|name[--content-type]|content-type].tpl.php, so:

field--field-name--content-type.tpl.php
field--content-type.tpl.php
field--field-name.tpl.php
field--field-type.tpl.php

I tried the following but, none have worked:

field--long-text--journal-page.tpl.php
field--long_text--journal_page.tpl.php
I just happened upon this question while trying to remember how to solve the same problem. In this case, Drupal simply doesn't do what you're asking for by default. There are two ways to approach it, one by accepting Drupal's default behaviour, and one by overriding that default.

Default behaviour

As has already been pointed out here, Drupal's template suggestions for fields don't consider the field type (though they do accommodate the content type).

Living with Drupal's default behaviour

This is the simplest solution, though it's a bit inflexible. Since your goal is to use only one template, what you can do is this:


Create a field template in our theme according to the field--field-name--content-type.tpl.php pattern. This will customize one of your fields.
Create symlinks to your original template containing the names of the other fields you need to customize.


For example, given fields with names lorem, ipsum, dolor and sit, and the content type contenttype, you'd create one template:


field--lorem--contenttype.tpl.php


Then, you'd create the following symlinks to that template:


field--ipsum--contenttype.tpl.php,
field--dolor--contenttype.tpl.php,
field--sit--contenttype.tpl.php


Drupal will see these as four different but identical files.

Overriding Drupal's default behaviour

The previous solution is quick and simple, but slightly unsatisfying. If Drupal's so flexible, we should be able to handle this problem using the Drupal API, right?

Well, it turns out we can. It's possible for us to add our own template suggestions.

We do this like this:

1. Implement template_preprocess_field()

/**
 * Implements template_preprocess_field().
 */
function THEMENAME_preprocess_field(&$variables) {
  if ($variables['element']['#bundle'] === 'contenttype' && $variables['element']['#field_type'] === 'text_long') {
    $variables['theme_hook_suggestions'][] = 'field__contenttype__text_long';
  }
}


2. Copy field.tpl.php to your theme

Copy field.tpl.php from modules/field/theme/field.tpl.php to sites/all/THEMENAME/field--contenttype--text-long.tpl.php and then customize to suit.



Notes


The logic in the template_preprocess_field() implementation could be changed in several ways, e.g. to match only by field name in a given content type instead of all examples of a field type in that content type.
The process is almost the same when doing this task in a module except that you'll also need an implementation of hook_theme() in the module to make it work.
It would be possible to to this using only theme_field(), but theme functions are deprecated in Drupal 8, so this is the method that we'll all be using going forward.