Problem/Motivation

On the template edit page there is a runtime error.

The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\Core\Field\BaseFieldDefinition::label() in Drupal\workbench_email\Plugin\RecipientType\EntityReferenceUser->buildConfigurationForm() (line 54 of modules/contrib/workbench_email/src/Plugin/RecipientType/EntityReferenceUser.php).
Drupal\workbench_email\Plugin\RecipientType\EntityReferenceUser->buildConfigurationForm() (Line: 237)
Drupal\workbench_email\Form\TemplateForm->form() (Line: 106)
Drupal\Core\Entity\EntityForm->buildForm()
call_user_func_array() (Line: 531)
Drupal\Core\Form\FormBuilder->retrieveForm() (Line: 278)
Drupal\Core\Form\FormBuilder->buildForm() (Line: 73)
Drupal\Core\Controller\FormController->getContentResult() (Line: 39)
Drupal\layout_builder\Controller\LayoutBuilderHtmlEntityFormController->getContentResult()
call_user_func_array() (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 564)
Drupal\Core\Render\Renderer->executeInRenderContext() (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext() (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw() (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle() (Line: 58)
Drupal\Core\StackMiddleware\Session->handle() (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle() (Line: 49)
Asm89\Stack\Cors->handle() (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle() (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle() (Line: 23)
Stack\StackedHttpKernel->handle() (Line: 709)
Drupal\Core\DrupalKernel->handle() (Line: 19)

Steps to reproduce

Created an email template and edit to see the error.

Proposed resolution

Replace label with getLabel.

-        $field_options[$entity_type_id . ':' . $field_name] = $sample_field->label() . ' (' . $entity_type->getLabel() . ')';
+        $field_options[$entity_type_id . ':' . $field_name] = $sample_field->getLabel() . ' (' . $entity_type->getLabel() . ')';

Remaining tasks

  • Review
  • RTBC
  • Rejoice

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 3307438-2.patch705 bytesjibran

Comments

jibran created an issue. See original summary.

jibran’s picture

Status: Active » Needs review
StatusFileSize
new705 bytes
larowlan’s picture

I think this happens when your field map is corrupt

larowlan’s picture

jibran’s picture

I think this happens when your field map is corrupt

Thank you for the suggestion I tired to rebuild the map but still can't get rid of the error but ::getLabel() exists on both \Drupal\Core\Field\BaseFieldDefinition and \Drupal\Core\Field\FieldDefinition and I think that is the right method to call.

  • larowlan committed 0dda232 on 2.x
    Issue #3307438 by jibran: Use getLabel() instead of label() on field...
larowlan’s picture

Status: Needs review » Fixed

Tagging 2.3.2

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.