function MediaSourceBase::prepareFormDisplay
Prepares the media type fields for this source in the form display.
This method should normally call \Drupal\Core\Entity\Display\EntityDisplayInterface::setComponent() or \Drupal\Core\Entity\Display\EntityDisplayInterface::removeComponent() to configure the media type fields in the form display.
Parameters
\Drupal\media\MediaTypeInterface $type: The media type which is using this source.
\Drupal\Core\Entity\Display\EntityFormDisplayInterface $display: The display which should be prepared.
Overrides MediaSourceInterface::prepareFormDisplay
2 calls to MediaSourceBase::prepareFormDisplay()
- OEmbed::prepareFormDisplay in core/
modules/ media/ src/ Plugin/ media/ Source/ OEmbed.php  - Prepares the media type fields for this source in the form display.
 - TestDifferentDisplays::prepareFormDisplay in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ TestDifferentDisplays.php  - Prepares the media type fields for this source in the form display.
 
3 methods override MediaSourceBase::prepareFormDisplay()
- OEmbed::prepareFormDisplay in core/
modules/ media/ src/ Plugin/ media/ Source/ OEmbed.php  - Prepares the media type fields for this source in the form display.
 - TestDifferentDisplays::prepareFormDisplay in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ TestDifferentDisplays.php  - Prepares the media type fields for this source in the form display.
 - TestWithHiddenSourceField::prepareFormDisplay in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ TestWithHiddenSourceField.php  - Prepares the media type fields for this source in the form display.
 
File
- 
              core/
modules/ media/ src/ MediaSourceBase.php, line 359  
Class
- MediaSourceBase
 - Base implementation of media source plugin.
 
Namespace
Drupal\mediaCode
public function prepareFormDisplay(MediaTypeInterface $type, EntityFormDisplayInterface $display) {
  // Make sure the source field is placed just after the "name" basefield.
  $name_component = $display->getComponent('name');
  $source_field_weight = $name_component && isset($name_component['weight']) ? $name_component['weight'] + 5 : -50;
  $display->setComponent($this->getSourceFieldDefinition($type)
    ->getName(), [
    'weight' => $source_field_weight,
  ]);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.