Problem/Motivation

After enabling the module and trying to set it as the formatter for a entity reference revisions field, the ajax loading failed with the following error in the logs:

Error: Call to a member function label() on null in Drupal\paragraphs_trimmed\Plugin\Field\FieldFormatter\ParagraphsTrimmedFormatterBase->settingsSummary() (line 142 of /app/docroot/modules/contrib/paragraphs_trimmed/src/Plugin/Field/FieldFormatter/ParagraphsTrimmedFormatterBase.php)
#0 /app/docroot/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(431): Drupal\paragraphs_trimmed\Plugin\Field\FieldFormatter\ParagraphsTrimmedFormatterBase->settingsSummary()
#1 /app/docroot/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php(40): Drupal\field_ui\Form\EntityDisplayFormBase->buildFieldRow(Object(Drupal\field\Entity\FieldConfig), Array, Object(Drupal\Core\Form\FormState))
#2 /app/docroot/core/modules/field_ui/src/Form/EntityDisplayFormBase.php(209): Drupal\field_ui\Form\EntityViewDisplayEditForm->buildFieldRow(Object(Drupal\field\Entity\FieldConfig), Array, Object(Drupal\Core\Form\FormState))
#3 /app/docroot/core/lib/Drupal/Core/Entity/EntityForm.php(106): Drupal\field_ui\Form\EntityDisplayFormBase->form(Array, Object(Drupal\Core\Form\FormState))
#4 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
#5 /app/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(531): call_user_func_array(Array, Array)
#6 /app/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(370): Drupal\Core\Form\FormBuilder->retrieveForm('entity_view_dis...', Object(Drupal\Core\Form\FormState))
#7 /app/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(628): Drupal\Core\Form\FormBuilder->rebuildForm('entity_view_dis...', Object(Drupal\Core\Form\FormState), Array)
#8 /app/docroot/core/lib/Drupal/Core/Form/FormBuilder.php(320): Drupal\Core\Form\FormBuilder->processForm('entity_view_dis...', Array, Object(Drupal\Core\Form\FormState))
#9 /app/docroot/core/lib/Drupal/Core/Controller/FormController.php(73): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\field_ui\Form\EntityViewDisplayEditForm), Object(Drupal\Core\Form\FormState))
#10 [internal function]: Drupal\Core\Controller\FormController->getContentResult(Object(Symfony\Component\HttpFoundation\Request), Object(Drupal\Core\Routing\RouteMatch))
#11 /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
#12 /app/docroot/core/lib/Drupal/Core/Render/Renderer.php(564): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#13 /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(124): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
#14 /app/docroot/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
#15 /app/vendor/symfony/http-kernel/HttpKernel.php(158): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
#16 /app/vendor/symfony/http-kernel/HttpKernel.php(80): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
#17 /app/docroot/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#18 /app/docroot/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#19 /app/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#20 /app/docroot/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#21 /app/docroot/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#22 /app/docroot/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#23 /app/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#24 /app/docroot/core/lib/Drupal/Core/DrupalKernel.php(709): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
#25 /app/docroot/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
#26 {main}

Looking at line 142 of /app/docroot/modules/contrib/paragraphs_trimmed/src/Plugin/Field/FieldFormatter/ParagraphsTrimmedFormatterBase.php the issue seems to be the hardcoding of full_html as the filter format. Since I installed Drupal with the minimal profile this format was not created by default.

Steps to reproduce

  1. Install Drupal with the minimal profile.
  2. Setup a entity reference revisions field for paragraphs.
  3. Try setting the field formatter to "Paragraphs Trimmed"
  4. Ajax loading should fail and an error logged.

Proposed resolution

Conditionally check if the full_html filter format is available, and if not, use the fallback format instead.

Remaining tasks

  1. Decide on solution.
  2. Create patch implementing solution.

User interface changes

None

API changes

None

Data model changes

None

CommentFileSizeAuthor
#2 filter_fallback-2956484-2.patch1.38 KBrik.henkie

Comments

PCate created an issue. See original summary.

rik.henkie’s picture

Status: Active » Needs review
StatusFileSize
new1.38 KB

I added the fallback to filter_format to the function.

pcate’s picture

Status: Needs review » Reviewed & tested by the community

Patch applied cleanly and fixed error.

  • geoanders committed feebba7 on 8.x-2.x
    Issue #3298960 - Error: Call to a member function label() on null.
    
geoanders’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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