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')
  ->setLabel('Image')
  ->setSettings([

... 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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
scroll top