I have a content entity type, and I would like to have an 'Upload file' field. I have declared the field in my Entity class $fields['file'] = BaseFieldDefinition::create('file') ->setLabel(t('Upload a file')) ->setDescription(t('Choose file from your computer')); And in EntityForm I am trying to set soma settings, because I need to make this dependable later with the '#states' $form['file'] = [ '#title' => $this->t('File'), '#description' => $this->t('Upload a file from your computer'), '#type' => 'file', '#default_value' => $entity->file->value, ]; But at the moment the field is displayed, but I have problems on saving the form. The file is attached, but not getting uploaded and the error says: Fatal error: Call to a member function getValue() on a non-object in C:\A plus\drupalsite\core\modules\file\src\Plugin\Validation\Constraint\FileValidationConstraintValidator.php on line 18