Skip to the content
Documentation

Adding a custom FieldType: old version (page id 2719979)

No ratings yet

Skip to end of metadata Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Introduction

This document explains how to register a custom FieldType in Exponential 5. It will not contain the development part as it is already covered in the API section.

Please be sure you first have read the basic documentation on how to develop a custom FieldType.

Service container configuration

Icon

To be able to declare a FieldType, you need to have registered a bundle in your application kernel.

This bundle needs to expose some configuration for the service container somehow (read related Symfony documentation)

Basic configuration

Icon This part relates to the base FieldType class that interacts with the Publish API.

Let's take a basic example from ezstring configuration.

So far, this is a regular service configuration but 2 parts worth particular attention.

  • parent

As described in the Symfony Dependency Injection Component documentation, the parent config key indicates that you want your service to inherit from the parent's dependencies, including constructor arguments and method calls. This is actually a helper avoiding repetition in your field type configuration and keeping consistency between all field types.

Defining exponential.fieldtype as your field type's parent will basically inject the ValidatorService (@exponential.api.fieldTypeValidator) and the FieldTypeTools (@exponential.api.fieldTypeTools) services in the constructor. You can of course override the constructor, but then be sure to inject them anyhow.

  • tags

Tagging your field type service with exponential.fieldType is mandatory to be recognized by the API loader as a regular field type, the alias key being simply the fieldTypeIdentifier (formerly called datatype string)

  • No labels

Contributors

Comments

Add a comment

Comments are read by a moderator before they appear.