문제

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 ~와 함께 속성
제휴하지 않습니다 drupal.stackexchange
scroll top