- Issue created by @arousseau
- 🇮🇳India Ishani Patel
Hello,
I've followed the steps and am facing the same issue. - 🇯🇵Japan ptmkenny
Thanks for reporting this.
The BaseFieldDefinition::create($type) is this one in SettingsForm.php?
foreach ($field_types as $name => $field_type) { // Special handling for preconfigured definitions. // @see \Drupal\Core\Field\FieldTypePluginManager::getUiDefinitions() $type = str_starts_with($name, 'field_ui:') ? $field_type['id'] : $name; $field_definition = BaseFieldDefinition::create($type);
We could probably follow the comment here and do something closer to what getUiDefinitions does in FieldTypePluginManager:
/** * {@inheritdoc} */ public function getUiDefinitions() { $definitions = $this->getDefinitions(); // Filter out definitions that can not be configured in Field UI. $definitions = array_filter($definitions, function ($definition) { return empty($definition['no_ui']); }); // Add preconfigured definitions. foreach ($definitions as $id => $definition) { if (is_subclass_of($definition['class'], '\Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface')) { foreach ($this->getPreconfiguredOptions($definition['id']) as $key => $option) { $definitions["field_ui:$id:$key"] = array_intersect_key( $option, ['label' => 0, 'category' => 1, 'weight' => 1, 'description' => 0] ) + $definition; } } } return $definitions; }
Also, I have documented that this module is not compatible with Data Field on the project page.
- 🇯🇵Japan ptmkenny
Ok, I looked into this more, and I think this may be a problem with the Data Field module, not Field Encrypt.
foreach ($field_types as $name => $field_type) { // Special handling for preconfigured definitions. // @see \Drupal\Core\Field\FieldTypePluginManager::getUiDefinitions() $type = str_starts_with($name, 'field_ui:') ? $field_type['id'] : $name; $field_definition = BaseFieldDefinition::create($type); $definitions = $field_definition->getPropertyDefinitions();
In this code, we are pulling in all the field types, including those with PreconfiguredFieldUiOptionsInterface. These preconfigured definitions do NOT include a name property, so the "special handling" gets the actual field type ID so that it can call BaseFieldDefinition::create(), and then we access getPropertyDefinitions().
It seems that DataFieldType relies on field_name being set, but this is not true for PreconfiguredFieldUiOptionsInterface field types.
- 🇫🇷France lazzyvn paris
I knew it. it write down in \datafield\src\Plugin\Field\FieldType\DataFieldItem.php
// Reset the field storage config property - it will be recalculated // when accessed via the property definition getter. // @see Drupal\field\Entity\FieldStorageConfig::getPropertyDefinitions() // If we don't do this, an exception is thrown during the table update that // is very difficult to recover from since the original field tables have // already been removed at that point. $field_storage_config = $form_state->getBuildInfo()['callback_object']->getEntity(); $field_storage_config->set('propertyDefinitions', NULL);
You will see the same error on the module having a dynamic subfield like double field, triple field...