Summary

In this chapter, we looked at how we can create custom fields that site builders (and developers) can add to entity types. This implied defining three plugin types: FieldType, FieldWidget, and FieldFormatter, each with its own responsibility. The first defined the actual field, its storage and individual data properties, using the TypedData API. The second defined the form through which users can input field data when creating or editing entities that use the field. The third defined how the values inside this field can be displayed when viewing the entity.

We also saw that each of these plugins can have arbitrary sets of configurable settings that can be used to make the field dynamic—both in how the widget works and in how the values are displayed. Moreover, these settings are part of the exported field configuration, so we saw how we can define their respective configuration schemas.

Lastly, we also saw how—aside from creating our new field through the UI—developers can add it to an entity type as a base field, making it available on all bundles of that entity type.

In the next chapter, we will talk about access control, a very important topic, as we need to ensure that our data and functionality are only exposed to the users we want, when we want.