Custom and Compound Fields in Drupal 8

tobby

Field API was introduced in Drupal 7 and heavily expanded and changed in Drupal 8. Creating custom fields elements and widgets is all part of the game of creating sites with complex data models.

Suppose you need to create a compound field, which consists of several different form elements (a select and several text fields). You can now create a basic compound field in three basic steps.

What is a compound field? Think of it as a single ingredient in a recipe. Each ingredient actually has multiple points of data: the amount, the metric (tsp, cup, ml, etc.), the ingredient itself, and maybe even a description of how it should be prepared. Each ingredient though is really a single field, with compound elements.

This session will walk through these steps, and discuss the many variations of what you can do with these fields, and how data can be processed and stored.

There are also a number of contrib modules that help build compound fields as well. Why write custom code when using existing modules will work? This sessions will examine several use cases to determine the best tool for the job.

Intended Audience: This is intended for developers who need complex data or custom data schemas and ways to manage it.

Session Track

Coding and Development

Experience Level

Intermediate

Drupal Version