Creating a Craft CMS Field Type

Examples of Field Types in Craft CMS

Craft CMS provides a bunch of field types as part of the core application. Some of the field types are specialized to Craft CMS functionality, like the Assets field or the Matrix field, and others you can get on the Craft Plugin Store.

As I men­tioned in the last video, Craft CMS pro­vides a bunch of field types as part of the core appli­ca­tion. Some of the field types are spe­cial­ized to Craft CMS func­tion­al­i­ty, like the Assets field or the Matrix field. 

But oth­ers, like Drop­down or Table fields, can be cus­tomized with your data. 

While these are the field types pro­vid­ed by default with Craft CMS, you can also add your own cus­tom field types to han­dle data sit­u­a­tions spe­cif­ic to your site’s imple­men­ta­tion. Most­ly com­mon­ly, you’ll find these cus­tom field types in plugins. 

For exam­ple, on CraftQuest, I use the Videos plu­g­in by Dukt. Videos is a plu­g­in that makes it easy to include videos from third-par­ty sources, like Vimeo or YouTube, and have pro­gram­mat­ic access to the video data. 

This plu­g­in pro­vides a cus­tom field type called Videos, which expos­es the plugin’s func­tion­al­i­ty as a field in your pub­lish layout. 

In the Craft Plu­g­in Store, there’s an entire cat­e­go­ry on Fields. These range from the Redac­tor WYSI­WYG field to the Recipe field for more eas­i­ly for­mat­ting recipe data, and to some­thing as sim­ple as a sin­gle cat­e­go­ry select field. If you want to share a cus­tom field with oth­ers that they can use on their projects, then you do it via a plugin.

How­ev­er, you don’t have to have a plu­g­in to cre­ate a cus­tom field. Some­times a project calls for a spe­cif­ic field that col­lects or retrieves data in a cer­tain way. 

In that case, you would use a mod­ule as the deliv­ery mech­a­nism for the field type. If you haven’t built a mod­ule before, check out my course My First Craft CMS Mod­ule, which will teach you the basics of build­ing a module. 

We’ll also build a sim­ple mod­ule in this course to house our cus­tom field types but I’ll link to the starter mod­ule to focus just on the field type and noth­ing else.

Okay, let’s get started!

Creating a Craft CMS Field Type is made up of the following videos: