I apologize if the answer to this is obvious, but I am newly-embarked on porting a number of complex custom Drupal 7 modules to Drupal 9. I am using Drupal version 9.3.6, PHP version 7.4.28, mysql, apache2.
I have created a custom field as follows, which on install goes without errors and appears in the field list report:
langcode: en
status: true
dependencies:
module:
- user
enforced:
module:
- test_module
id: user.field_test
field_name: field_test
entity_type: user
type: string_long
settings:
case_sensitive: false
module: core
locked: false
cardinality: 1
translatable: true
indexes: { }
persist_with_no_fields: false
custom_storage: false
But when I try to instantiate it, either with field.field.user.user.field_test.yml or manually through the UI, I get the following error stack:
[warning] A non-numeric value encountered TypedConfigManager.php:189
[error] Error: Unsupported operand types in Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements() (line 189 of /var/www/test_site/web/core/lib/Drupal/Core/Config/TypedConfigManager.php) #0 /var/www/test_site/web/core/lib/Drupal/Core/Config/TypedConfigManager.php(105): Drupal\Core\Config\TypedConfigManager->getDefinitionWithReplacements()
(Sorry, I had to delete the remainder of the stack dump to avoid getting flagged as spam!)
This is the part of TypedConfigManager as follows:
// Add type and default definition class.
$definition += [
'definition_class' => '\Drupal\Core\TypedData\DataDefinition', // Here is line 189
'type' => $type,
'unwrap_for_canonical_representation' => TRUE,
];
return $definition;
I am at a loss here. If I create the field storage through the admin interface and instantiate also through the admin interface, everything works fine. I export those definitions through the single export interface, and then I get the failure.
Thank you in advance for any insight!
Update: @Jaypan, here is the code for the field.field:
langcode: en
status: true
dependencies:
config:
- field.storage.user.field_test
module:
- user
enforced:
module:
- test_module
id: user.user.field_test
field_name: field_test
entity_type: user
bundle: user
label: 'Test field'
description: ''
required: false
translatable: false
default_value: { }
default_value_callback: ''
settings: { }
field_type: string_long