function MediaSourceBase::buildConfigurationForm
Same name in other branches
- 9 core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::buildConfigurationForm()
- 8.9.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::buildConfigurationForm()
- 11.x core/modules/media/src/MediaSourceBase.php \Drupal\media\MediaSourceBase::buildConfigurationForm()
Overrides PluginFormInterface::buildConfigurationForm
2 methods override MediaSourceBase::buildConfigurationForm()
- OEmbed::buildConfigurationForm in core/
modules/ media/ src/ Plugin/ media/ Source/ OEmbed.php - Form constructor.
- Test::buildConfigurationForm in core/
modules/ media/ tests/ modules/ media_test_source/ src/ Plugin/ media/ Source/ Test.php - Form constructor.
File
-
core/
modules/ media/ src/ MediaSourceBase.php, line 174
Class
- MediaSourceBase
- Base implementation of media source plugin.
Namespace
Drupal\mediaCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$options = $this->getSourceFieldOptions();
$form['source_field'] = [
'#type' => 'select',
'#title' => $this->t('Field with source information'),
'#default_value' => $this->configuration['source_field'],
'#empty_option' => $this->t('- Create -'),
'#options' => $options,
'#description' => $this->t('Select the field that will store essential information about the media item. If "Create" is selected a new field will be automatically created.'),
];
if (!$options && $form_state->get('operation') === 'add') {
$form['source_field']['#access'] = FALSE;
$field_definition = $this->fieldTypeManager
->getDefinition(reset($this->pluginDefinition['allowed_field_types']));
$form['source_field_message'] = [
'#markup' => $this->t('%field_type field will be automatically created on this type to store the essential information about the media item.', [
'%field_type' => $field_definition['label'],
]),
];
}
elseif ($form_state->get('operation') === 'edit') {
$form['source_field']['#access'] = FALSE;
$fields = $this->entityFieldManager
->getFieldDefinitions('media', $form_state->get('type')
->id());
$form['source_field_message'] = [
'#markup' => $this->t('%field_name field is used to store the essential information about the media item.', [
'%field_name' => $fields[$this->configuration['source_field']]
->getLabel(),
]),
];
}
return $form;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.