Skip to content

Instantly share code, notes, and snippets.

@JeromeChevalier
Last active February 21, 2021 13:53
Show Gist options
  • Save JeromeChevalier/8da086f2320a5d2f7860f7edb2ad51ce to your computer and use it in GitHub Desktop.
Save JeromeChevalier/8da086f2320a5d2f7860f7edb2ad51ce to your computer and use it in GitHub Desktop.
Create a entity basefield as with a file type #drupal8
$fields['download_file'] = BaseFieldDefinition::create('file')
->setLabel(t('Forecast data'))
->setSetting('file_directory', 'forecast')
->setSetting('max_filesize', '10MB')
->setSetting('file_extensions', 'csv')
->setSetting('description_field', FALSE)
->setDisplayOptions('form', [
'label' => 'hidden',
'type' => 'file_generic',
'weight' => 4,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment