field

8: Compound (bundled) fields - your new best friend - Part 5

the Twig file

In the previous section we created the file that defines the widget formatter used to pre-format the data before passing it on to a twig file. In this part we will create the twig file that provides the markup for the viewed content.

name_field_type.html.twig

The file should be placed in the path <my module>/templates and be given the name used for #theme in the previous section with a .twig suffix.


{{ name }}

 

8: Compound (bundled) fields - your new best friend - Part 3

the Field Type Widget definition

In the previous section created the field type definition that will be used to attach the field type to a content type. In this section, we will create the file that defines the widget used on the node form to represent the field type.

NameFieldTypeDefaultWidget.php

The default widget file defines the appearance of the field type as it appears on the node form. The name of the file (less the .php extension) will also be the name of the class defined within the file. The file should be placed in the path

8: Compound (bundled) fields - your new best friend - Part 2

the Field Type Item definition

In the previous section we learned what a compound/bundled field is, and defined the module files that will wrap our field type plugin. In this section, we will create the file that defines the field type and which sub-fields compose it.

NameItem.php

The field file defines the structure of the field type. The name of the file (less the .php extension) will also be the name of the class defined within the file. The file should be placed in the path <my module>/src/Plugin/Field/FieldType.

Subscribe to field
Of course, the Drupal Community isn't the only place to give back. It's a complex world, and there are as many worthy causes as their are melodies, with most being served by multiple charitable organizations. Here are a few of those that strike a 7th chord with me.