Creating a Craft CMS Field Type
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 create Publish Layouts for your Craft CMS project. A field type is not just an HTML element, 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 element it uses plus the functionality it provides. The field type you choose will determine the UI and the kind of data that it can store.
As an example, with the HTML element select
. On its own, it allows you to select one item from a list of many via a simple touchable or clickable interface.
The in-built version of this in Craft is the Dropdown Field. It functions just like a select
element, but Craft gives you the ability to create a new instance of the Dropdown field and set the options via a setting UI in the Craft control panel.
You can then use the Dropdown Field in a Craft publish layout to collect information for a Craft element, like an entry, category, or asset.
Additionally, when you want to query for an element that has the Dropdown field you created and display it in a Twig template, Craft provides ways to access the data stored by that instance of the field.
Creating a Craft CMS Field Type is made up of the following videos: