In a module I am working on, I'd like to create a file field. I am baffed why I can't find any proper documentation on that.

$fields['fid'] = BaseFieldDefinition::create('file')

... so what settings are available? What can I do with a field of type file? How do paths work under Drupal, what about permissions... Is there somewhere a proper, complete documentation for these things?

1 Answer 1


The settings depend on the field type, widget and formatter plugins you use, which can be core, contrib or custom. These plugins usually don't have documentation, but they provide the options in UI. So the easiest way would be to configure the field in UI, export the config and then transfer YAML to PHP array syntax of the base field definition. Most times a better approach, though, is to keep the field in configuration and install it as module default config.


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