D7 to D8 upgrade: fields, widgets and formatters

Why not try the example module explained on this page yourself? Download

For fields, their widgets and their formatters, hook-implementations in D7 are replaced by classes with annotations in D8. For instance, the schema definition that used to live in the .install file has moved to the class that lives in modulename/lib/Drupal/modulename/Plugin/Field/FieldType/ModuleNameItem.php. So often, after upgrading your project won't have a .install file anymore.

Here's in summary what you'll have to add to re-instate the functionality provided by your field hook implementations.
In the /modules/modulename/lib/Drupal/modulename/Plugin/Field folder you need to create the 3 following files, each holding a class and its magic annotations.

  • .../FieldType/ModuleNameItem.php
  • .../FieldWidget/ModuleNameWidget.php
  • .../FieldFormatter/ModuleNameFormatter.php

Below are examples of the files above, plus .info.yml and .module files that when put together form a working example of a module that programmatically creates a text field, widget and formatter. Through the "Manage fields" UI this field may be attached to any entity type.

Contributing to Symfony Documentation

THIS PAGE IS A WORK IN PROGRESS... It should have more information shortly!

This document covers updating documentation (online and API) for the Symfony component of Drupal (adopted in Drupal version 8).

Background and Overview

In Drupal version 8, the Drupal Core project adopted several third-party libraries into its source code, including the Symfony web development framework. The Symfony library is under directory core/vendor/symfony in the Drupal core source code (version 8), and other PHP-based libraries are in other directories under core/vendor. There are also third-party JavaScript libraries in Drupal, such as JQuery (which has been part of Drupal for many versions); these have traditionally been located in the "misc" directory, mixed in with Drupal-native JavaScript libraries.

If you find an error or omission in Symfony's documentation and would like to contribute to the Drupal and Symfony projects by fixing it (or at least pointing it out), the basic steps are the same as contributing to the Drupal API documentation:

Subscribe with RSS Subscribe to RSS - symfony