I have a custom field setup that I created similar to this tutorial. I exported all my fields on my node to a test module and enable it during my PHPUnit test.
I run my test with the following command:
php ./core/scripts/run-tests.sh --verbose --php /usr/local/bin/php --url http://nginx --class "Drupal\my_module\Tests\ExpenseTest"
And I get the following error:
The test did not complete due to a fatal error.
Exception Uncaught e ConfigSchemaCheck 95 Drupal\Core\Config\Development\Conf
Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for
core.entity_form_display.paragraph.my_field.default with the
following errors:
core.entity_form_display.paragraph.my_field.default:content.field_city_state.settings.size
missing schema,
core.entity_form_display.paragraph.my_field.default:content.field_city_state.settings.autocomplete_route_name
missing schema,
core.entity_form_display.paragraph.my_field.default:content.field_city_state.settings.placeholder
missing schema in
Drupal\Core\Config\Development\ConfigSchemaChecker->onConfigSave() (line
95 of
This is part of my core.entity_form_display.paragraph.my_field.default.yml file:
field_city_state:
weight: 2
settings:
size: '60'
autocomplete_route_name: my_module.city_autocomplete
placeholder: ''
third_party_settings: { }
type: city_state_default
region: content
If I remove the settings it doesn't give me the error (Although I am not testing that field yet).
This is my module's Field Type Class:
<?php
namespace Drupal\my_module\Plugin\Field\FieldType;
use Drupal\Core\Field\FieldItemBase;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\Field\FieldItemInterface;
/**
* Plugin implementation of the 'city_state' field type.
*
* @FieldType(
* id = "city_state",
* label = @Translation("City/State"),
* description = @Translation("An entity field containing city/state"),
* category = @Translation("Address"),
* default_widget = "city_state_default",
* default_formatter = "city_state_default"
* )
*/
class CityStateItem extends FieldItemBase implements FieldItemInterface {
/**
* {@inheritdoc}
*/
public static function schema(FieldStorageDefinitionInterface $field_definition) {
return [
'columns' => [
'state_code' => [
'type' => 'varchar',
'length' => 2,
],
'city' => [
'type' => 'varchar',
'length' => 255,
],
],
];
}
/**
* {@inheritdoc}
*/
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
$properties['state_code'] = DataDefinition::create('string')->setLabel(t('State Code'));
$properties['city'] = DataDefinition::create('string')->setLabel(t('City'));
return $properties;
}
/**
* {@inheritdoc}
*/
public function isEmpty() {
$value = $this->state_code;
return $value === NULL || $value === '';
}
/**
* Get city string.
*
* @return string
* Returns city name.
*/
public function getCity() {
return $this->city;
}
/**
* Get state code string.
*
* @return string
* Returns the state code.
*/
public function getStateCode() {
return $this->state_code;
}
}
This is my module's schema file:
city_state:
type: mapping
label: 'City/State settings'
mapping:
state_code:
type: string
label: 'State Code'
city:
type: string
label: 'City'
Don't understand why I am getting this error and only during Testing. (No issues when running config import on dev and staging).
settings: { }
I was able to still save to the custom field.