- Issue created by @aluzzardi
Seems that Custom Entity that extend ContentEntityBase with file managed does not have third party settings
Error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::getThirdPartySettings() in file_field_replace_field_widget_single_element_form_alter() (line 134 of modules/contrib/file_field_replace/file_field_replace.module).
Drupal\Core\Extension\ModuleHandler->alter('field_widget_single_element_form', Array, Object, Array) (Line: 351)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 167)
Drupal\file\Plugin\Field\FieldWidget\FileWidget->formMultipleElements(Object, Array, Object) (Line: 111)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 183)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 372)
Drupal\nbhc_indicator_categories_field\Plugin\Field\FieldWidget\IndicatorCategoriesWidget->formElement(Object, 4, Array, Array, Object) (Line: 340)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 4, Array, Array, Object) (Line: 132)
Drupal\nbhc_indicator_categories_field\Plugin\Field\FieldWidget\IndicatorCategoriesWidget->formMultipleElements(Object, Array, Object) (Line: 111)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 183)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 121)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 127)
Drupal\node\NodeForm->form(Array, Object) (Line: 107)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 536)
Drupal\Core\Form\FormBuilder->retrieveForm('node_data_table_edit_form', Object) (Line: 283)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object) (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Create a Custom Content Entity and add a field with File managed:
$fields['icon'] = BaseFieldDefinition::create('file')
->setLabel(t('Icon'))
->setSetting('file_extensions', 'svg png')
->setDisplayOptions('view', [
'label' => 'above',
'type' => 'image',
'weight' => 7,
])
->setDisplayOptions('form', [
'type' => 'image_image',
'weight' => 7,
])
->setDisplayConfigurable('form', TRUE)
->setDisplayConfigurable('view', TRUE);
Update the check on the function file_field_replace_field_widget_single_element_form_alter to validate if the field definitions has the function getThirdPartySettings.
Active
3.0
Code