I have the dev release running on my site (Drupal 8.2.3) and when I choose the Field Formatter with Inline Options, it causes the following error

TypeError: Argument 1 passed to Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterWithInlineSettings::getFieldDefinition() must implement interface Drupal\Core\Field\FieldStorageDefinitionInterface, null given, called in /modules/contrib/field_formatter/src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php on line 123 in/modules/contrib/field_formatter/src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php on line 109 

#0 /modules/contrib/field_formatter/src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php(123): Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterWithInlineSettings->getFieldDefinition(NULL)
#1 /modules/contrib/field_formatter/src/Plugin/Field/FieldFormatter/FieldFormatterWithInlineSettings.php(224): Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterWithInlineSettings->getAvailableFormatterOptions(NULL)
#2 /core/modules/field_ui/src/Form/EntityDisplayFormBase.php(408): Drupal\field_formatter\Plugin\Field\FieldFormatter\FieldFormatterWithInlineSettings->settingsForm(Array, Object(Drupal\Core\Form\FormState))
#3 /core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php(36): Drupal\field_ui\Form\EntityDisplayFormBase->buildFieldRow(Object(Drupal\field\Entity\FieldConfig), Array, Object(Drupal\Core\Form\FormState))
#4 /core/modules/field_ui/src/Form/EntityDisplayFormBase.php(180): Drupal\field_ui\Form\EntityViewDisplayEditForm->buildFieldRow(Object(Drupal\field\Entity\FieldConfig), Array, Object(Drupal\Core\Form\FormState))
#5 /core/lib/Drupal/Core/Entity/EntityForm.php(115): Drupal\field_ui\Form\EntityDisplayFormBase->form(Array, Object(Drupal\Core\Form\FormState))
#6 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
...

The field is an entity reference to an image media entity (module media_entity_image).

Comments

xenophyle created an issue. See original summary.

bkhandruk’s picture

Added a check to avoid getting formatter options when there is no definition for specified field.

bkhandruk’s picture

Status: Active » Needs review
slashrsm’s picture

Status: Needs review » Needs work
Issue tags: +D8Media

Could you provide some steps to reproduce the problem. It would be also nice if we'd add the test coverage to prevent us from re-introducing this regression in the future.

slashrsm’s picture

Issue tags: +Needs tests
marcoscano’s picture

seanb’s picture

StatusFileSize
new1.72 KB
new720 bytes

Small extra fix that made it work for me. When you have the entity referenced field set on 'Rendered entity' and switch to 'Field formatter with inline settings' this occurs.
Needed a small extra fix to make it work though. Patch is attached.

This inline formatter will probably end up in core for 8.4 btw #2831943: Use "rendered media" (not links) as default media field formatter; add modal to configure the used media view mode

grimreaper’s picture

Hello,

Patch from comment 2 solved the issue.

Steps to reproduce :
- on a fresh drupal install
- enable media module
- add an entity reference field to a media entity on a content type
- go to the manage display of the content
- select the formatter "Field formatter with inline settings" (so before the default formatter is "label")
- ajax error

tim-diels’s picture

The patch of #2 works perfect

anybody’s picture

Status: Needs work » Reviewed & tested by the community

We're been using patch #7 on several sites without any problems. I'll set this RTBC, is there a plan for the next release which may include this?

  • Anybody committed 7a2d661 on 8.x-1.x authored by seanB
    Issue #2831921 by seanB, rocket.man, Grimreaper, Anybody: Error with...
anybody’s picture

Status: Reviewed & tested by the community » Fixed

Commited, thank you all!

anybody’s picture

Created a new stable 1.2 release. Patches for tests are still very welcome.

grimreaper’s picture

Status: Fixed » Needs work
StatusFileSize
new44.34 KB

Hello,

On the 8.x-1.2 version, with responsive image there is a problem.

I want to avoid to have to create view modes on media entity for the different image styles.

When using the formatter "Field formatter with inline settings":

  1. I can select the image field: OK
  2. Even if there is a responsive image style, it is not in the options and as the field is required, it prevents to select another formatter: KO

See attached screenshot.

Thanks for any help.

grimreaper’s picture

Status: Needs work » Fixed

Sorry for the double post.

I found why my responsive image style was not appearing (wrong configuration). So I can select it and so select another formatter.

But I think the problem will be back for any field formatter with a mandatory field without option.

Status: Fixed » Closed (fixed)

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