What is a Field Type in Craft CMS?

Field types in Craft can be any of those but what makes a field type a Craft CMS field type is the HTML element it uses plus the functionality it provides.

A field type is a type of input field that you use to cre­ate Pub­lish Lay­outs for your Craft CMS project. A field type is not just an HTML ele­ment, like an input field, textarea, or select. 

Field types in Craft can be any of those, but what makes a field type a Craft CMS field type is the HTML ele­ment it uses plus the func­tion­al­i­ty it pro­vides. The field type you choose will deter­mine the UI and the kind of data that it can store.

As an exam­ple, with the HTML ele­ment select. On its own, it allows you to select one item from a list of many via a sim­ple touch­able or click­able interface.

The in-built ver­sion of this in Craft is the Drop­down Field. It func­tions just like a select ele­ment, but Craft gives you the abil­i­ty to cre­ate a new instance of the Drop­down field and set the options via a set­ting UI in the Craft con­trol panel. 

You can then use the Drop­down Field in a Craft pub­lish lay­out to col­lect infor­ma­tion for a Craft ele­ment, like an entry, cat­e­go­ry, or asset. 

Addi­tion­al­ly, when you want to query for an ele­ment that has the Drop­down field you cre­at­ed and dis­play it in a Twig tem­plate, Craft pro­vides ways to access the data stored by that instance of the field.

Transcript

Premium

Follow along with the full transcript

Search every word, click any line to jump to that moment, and read along as you watch — a CraftQuest Premium feature.

Sign up for Premium
Craft Version
Craft 4
Instructor
Level
Intermediate
Date Published
May 12, 2021