Field formatters are how we control how the contents of a particular field gets displayed to the user, they are exposed under the display settings for your entity and can be as simple as configuring a date format right the way through to more complex, bespoke display requirements such as displaying images in a gallery format. Drupal ships with a number of field formatters out of the box and there's a wide range available in the form of contributed modules and of course it is possible to create your own! Find out more about field formatters by reading some of our blog posts below...
Upgrading to Drupal 9
Many of us at ComputerMinds have always taken pride on doing Drupally things the right way whenever possible, and then helping the community do so too. One of these things is displaying values from fields on content entities. We wrote before about how to do this in Drupal 7 and Drupal 8. It's now the turn of Drupal 9! Thankfully, this updated version is basically the same as the last one, as D9 is very...
Once upon a time, we wrote an article about how to render fields on their own in Drupal 7, which was really handy because Drupal 7 wasn't always intuitive. It's common to want to display a field outside of the context of its main entity page, like showing author information in a sidebar block or in a panel, but you had to just know which functions to use. Drupal 8 came along since then using...
This is part 3 in my series of articles about creating a custom field. I recommend reading Part 1: Field type and Part 2: Field widget first, if you have not done so already. After creating the field type and field widget it is now time to complete the set by creating the field formatter. ##a) Create the file The field type must be located as follows: /lib/Drupal/ /Plugin/field/formatter/ .php
N.B. The field formatter...
Creating extra field formatters in Drupal 7 is fairly simple, but it can take some poking around in the new Fields code. So here is some sample code to make it easier for you! You can add formats to your own fields -- or existing fields that are defined by other Drupal modules. This is the case for the following example - a formatter for a link field to display the URL as an absolute...