> For the complete documentation index, see [llms.txt](https://drupal.bermaki.com/drupal-documentation-and-guides/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://drupal.bermaki.com/drupal-documentation-and-guides/guides/custom-fields.md).

# Custom Fields

Sometimes you need to create your own custom fields or group of fields to your models. This is a guide on how to do that. Although there is an example at the [Examples for developers](https://git.drupalcode.org/project/examples/-/tree/3.x/modules/field_example) module, i found it lacking in some areas. So i decided to create my own example.

We will be leveraging the [Field API](https://www.drupal.org/docs/8/api/entity-api/field-api) to create our custom fields. which means we will need to create a `FieldType`, `FieldWidget` and `FieldFormatter`. we will create these files in the `src/Plugin/Field/FieldType`, `src/Plugin/Field/FieldWidget` and `src/Plugin/Field/FieldFormatter` directories.

{% content-ref url="/pages/UEsns5QCnVCHDygOAIVB" %}
[Entity Reference and integer](/drupal-documentation-and-guides/guides/custom-fields/entity-reference-and-integer.md)
{% endcontent-ref %}

{% content-ref url="/pages/p6PpnoP8kmSlWBoWbcnO" %}
[Two Text Fields](/drupal-documentation-and-guides/guides/custom-fields/two-text-fields.md)
{% endcontent-ref %}

{% content-ref url="/pages/H9QGiMJRhOYJjENht414" %}
[Textfields, formatted text and numbers](/drupal-documentation-and-guides/guides/custom-fields/textfields-formatted-text-and-numbers.md)
{% endcontent-ref %}

{% content-ref url="/pages/H2J4UtMmouNTMD6jpGOX" %}
[Links and media elements](/drupal-documentation-and-guides/guides/custom-fields/links-and-media-elements.md)
{% endcontent-ref %}
