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
The main value of YouTubeItem FieldType is named "input" instead of "value" in FieldItemBase class.
We've a problem when try to retrieve the value of the field.
Example in a media provider :
$source_field = $this->configuration['source_field'];
$property_name = $media->{$source_field}->first()->mainPropertyName(); // will return "value" instead of "input"
dpm($media->{$source_field}->{$property_name}); // will retrieve nothing
Proposed resolution
Just override mainPropertyName() method and return "input" instead of "value".
Comment | File | Size | Author |
---|---|---|---|
#2 | override-mainPropertyName-method-2569625-1.patch | 453 bytes | jeanfei |
Comments
Comment #2
jeanfei CreditAttribution: jeanfei commentedHere the patch !
Comment #3
jeanfei CreditAttribution: jeanfei commentedComment #5
guschilds CreditAttribution: guschilds at Chromatic commentedThanks for the patch and example code! I've committed it to the 8.x-1.x branch.
Comment #6
jeanfei CreditAttribution: jeanfei commentedGreat, thanks !