I just read Create a custom field type and I can't find a lot of information about the .schema.yml file. So, I just create a custom field without the .schema.yml file and I see that if I add my custom field in a content type and I export my config the field is exported with all the configuration.

So we really need the schema.yml file when I create a new custom field?


To make sure configuration and default values are using the correct types, there can be tricky bugs related to float/int for example.

If you have interface strings in your settings, you can also use the config schema definitions to make them translatable.

And it can be used to validate configuration.

Config schema is not enforced by default, see https://www.drupal.org/node/2625212. But it enforced by default in tests, so try to write a test that creates a field of your type and it will complain and tell you what schema is missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.