Problem/Motivation

When you create a new view and add custom field with entity reference (user) and change widget to Rendered entity (default) log shows following warning:

Warning: Undefined array key "view_mode" in Drupal\custom_field\Plugin\CustomField\FieldFormatter\EntityReferenceEntityFormatter->formatValue() (line 105 of \web\modules\contrib\custom_field\src\Plugin\CustomField\FieldFormatter\EntityReferenceEntityFormatter.php)
CommentFileSizeAuthor
#3 custom_field-3437107.patch832 bytesabhishek_gupta1
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

coaston created an issue. See original summary.

abhishek_gupta1’s picture

Assigned: Unassigned » abhishek_gupta1
abhishek_gupta1’s picture

Assigned: abhishek_gupta1 » Unassigned
Status: Active » Needs review
StatusFileSize
new832 bytes

@coaston , I have fixed the issue please review the patch file

manish-31 made their first commit to this issue’s fork.

manish-31’s picture

@abhishek_gupta1 Thanks for the patch!

Made one change : setting default instead of NULL when view mode is not available in widget settings.

I have raised MR for the fix. Needs review.

apmsooner’s picture

Theres actually a better fix for this and other related tickets that I will push up here in a bit. First off, this formatter needs to have default settings merged in with actual settings and then view_mode will always exist. The bigger underlying issue is in the base formatter as it needs to respond to field changes and serve the default formatter in case the already saved formatter doesn't relate to the field type. I will tag that issue in a separate ticket and link these up but this should resolve all formatter issues.

apmsooner’s picture

Status: Needs review » Fixed

Addressed in this commit: https://git.drupalcode.org/project/custom_field/-/commit/bc7495df778829b.... You can test latest dev branch to confirm and reopen separate issue if you are still seeing problems but this should be resolved now with the default settings merged in.

apmsooner’s picture

Status: Fixed » Closed (fixed)