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".

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jeanfei created an issue. See original summary.

jeanfei’s picture

Here the patch !

jeanfei’s picture

Status: Needs work » Needs review

  • guschilds committed 44fd0f2 on 8.x-1.x authored by jeanfei
    Issue #2569625 by jeanfei: Override mainPropertyName method for...
guschilds’s picture

Status: Needs review » Fixed

Thanks for the patch and example code! I've committed it to the 8.x-1.x branch.

jeanfei’s picture

Great, thanks !

Status: Fixed » Closed (fixed)

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