Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#3 | 2492241-field-settings-display-field-not-set.patch | 1.7 KB | Dave Reid |
#1 | 2492241-1.patch | 596 bytes | dawehner |
Comments
Comment #1
dawehnerHere is an easy fix.
Comment #2
das-peter CreditAttribution: das-peter commentedLogic isn't changed here - besides avoiding a notice.
So I'd say RTBC.
Comment #3
Dave ReidTurns out we kind of have the same logic in media_field_widget_form() so I'd like to combine the two approaches.
Comment #4
Dave ReidCommitted #3 to 7.x-2.x.