Problem/Motivation

When you have a media field as part of a field collection you can easily run into the following notice:

Notice: Undefined index: display_field in includes/media.fields.inc on line 192

A similar problem exists for ordinary file fields, see #1430934: Notice: Undefined index: display_field in file_field_widget_value() (line 582 of /module/file/file.field.inc).

Proposed resolution

Use !empty() to ensure that the value might not exist.

Previous issuesin core solved it by adding the value in the widget form, see #714350: Undefined index: display_field in file_field_widget_form() in file.field.inc

Remaining tasks

User interface changes

API changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dawehner’s picture

Status: Active » Needs review
FileSize
596 bytes

Here is an easy fix.

das-peter’s picture

Status: Needs review » Reviewed & tested by the community

Logic isn't changed here - besides avoiding a notice.
So I'd say RTBC.

Dave Reid’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.7 KB

Turns out we kind of have the same logic in media_field_widget_form() so I'd like to combine the two approaches.

Dave Reid’s picture

Status: Needs review » Fixed

Committed #3 to 7.x-2.x.

  • Dave Reid committed dea5d0a on 7.x-2.x
    Issue #2492241 by dawehner, Dave Reid: Fixed PHP notice: Undefined index...

Status: Fixed » Closed (fixed)

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