function _insert_media_settings_form in Insert 8.2
Parameters
array $settings:
Return value
array
1 call to _insert_media_settings_form()
- insert_media_field_widget_third_party_settings_form in modules/
insert_media/ insert_media.module - Implements hook_field_widget_third_party_settings_form().
File
- modules/
insert_media/ insert_media.module, line 66
Code
function _insert_media_settings_form(array $settings) {
$viewModes = _insert_media_get_view_modes();
if (count($viewModes) === 0) {
return [];
}
$element = [
'#type' => 'details',
'#title' => t('Insert Media'),
'#weight' => 20,
];
$element['view_modes_heading'] = [
'#type' => 'markup',
'#markup' => t('Select which view modes should be available for inserting media. If no view mode is selected, no Insert functionality will be available; If only one view mode is selected, that one is used automatically when inserting. If all view modes are selected, new view modes will be enabled by default.'),
'#weight' => 21,
];
$element['view_modes'] = [
'#type' => 'table',
'#default_value' => $settings['view_modes'],
'#element_validate' => [
[
InsertUtility::class,
'validateList',
],
],
'#weight' => 22,
'#tableselect' => TRUE,
'#header' => [
t('Select all'),
],
];
foreach ($viewModes as $id => $viewMode) {
$element['view_modes'][$id][$id] = [
'#type' => 'markup',
'#markup' => $viewMode
->label(),
];
}
$element['default'] = [
'#title' => t('Default view mode'),
'#type' => 'select',
'#options' => array_map(function ($viewMode) {
/** @var \Drupal\Core\Entity\EntityViewModeInterface $viewMode */
return $viewMode
->label();
}, $viewModes),
'#default_value' => $settings['default'],
'#description' => t('Select the view mode which will be selected by default or used if no other view modes are enabled above.'),
'#weight' => 23,
];
return $element;
}