- Issue created by @harkonn
Lightnings issue
#3067814 Hide the revision UI on media forms by default →
and Drupal 10.2.0 new feature
Media now provides a UI for viewing, reverting and deleting revisions →
are not properly compatible. It feels like the core feature is a successor these days and we can end up showing the field revision_log_message
in form display despite having disabled the ui in lightning_media.settings.revision_ui.
1. Install recommended project >= 10.2
2. Install lightning_media (no submodules needed) and its needed dependencies
3. Disable lightning_media.settings.revision_ui
4. Activate revision_log_message in form display of document
5. Edit a media document element with Claro admin ui (see screenshot)
Since lightning_media is not maintained for real new released anymore and this would need a kind of rewrite of config for lightning_media in Drupal >= 10.2 the situation is kind of messy now.I dont feel like putting work in a merge-request would end in a new release since the last updates to the dev-branch is from january 2023 and lightnings end of life partially is some time ago.
I wrote my own update-hook to smoothen the config in our own projects, maybe the code helps some of you:
function mymodule_update_10001(&$sandbox) {
if (\Drupal::moduleHandler()->moduleExists('lightning_media')) {
$configFactory = \Drupal::configFactory();
// set global lightning setting for media
$configFactory
->getEditable('lightning_media.settings')
->set('revision_ui', TRUE)
->save();
// get all media form displays
$config_names = $configFactory->listAll('core.entity_form_display.media');
foreach ($config_names as $config_name) {
// only change default form display
if (str_contains($config_name, '.default')) {
$config = $configFactory->getEditable($config_name);
$hidden = $config->get('hidden');
// is it hidden?
if ($hidden['revision_log_message']) {
$content = $config->get('content');
// add to content
$content += [
'revision_log_message' => [
'type' => 'string_textarea',
'region' => 'content',
'settings' => [
'rows' => 4,
'placeholder' => '',
],
'third_party_settings' => [],
]
];
$config->set('content', $content);
// remove from hidden
unset($hidden['revision_log_message']);
$config->set('hidden', $hidden);
$config->save(TRUE);
}
}
}
}
}
Active
5.0
Code