- We will need to create the src/Plugin/Field/FieldType directory in the module's base location. The Field module discovers field types in the Plugin\Field\FieldType namespace.
- We will create a RealName.php file in the newly created directory so that we can define the RealName class. This will provide our realname field for the first and last names:
- The RealName class will extend the \Drupal\Core\Field\FieldItemBase class:
<?php namespace Drupal\mymodule\Plugin\Field\FieldType; use Drupal\Core\Field\FieldItemBase; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\TypedData\DataDefinition; class RealName ...