Skip to content
Snippets Groups Projects
Commit 16fbaa0f authored by Nikolay Grachev's avatar Nikolay Grachev
Browse files

Issue #3374512 by jdhildeb, ilfelice, granik: Only compatible with Claro (admin) theme?

parent 3a987bb4
No related branches found
No related tags found
No related merge requests found
......@@ -64,36 +64,6 @@ function file_rename_field_widget_single_element_form_alter(&$element, FormState
}
/**
* Beatify rename button position on image widget.
*
* Implements hook_preprocess_HOOK().
*/
function file_rename_preprocess_image_widget(&$variables) {
if (isset($variables['data']['rename_link'])) {
// Place 'Rename' button next to 'Remove'.
$variables['main_items']['rename_link'] = $variables['data']['rename_link'];
unset($variables['data']['rename_link']);
}
}
/**
* Beatify rename button position on file widget.
*
* Implements hook_preprocess_HOOK().
*
* @todo Multiple file field is not fully supported yet.
* On remove one of the files the Rename button disappears.
* See: https://www.drupal.org/project/drupal/issues/3177977
*/
function file_rename_preprocess_file_managed_file(&$variables) {
if (isset($variables['element']['rename_link'])) {
// Place 'Rename' button next to 'Remove'.
$variables['main_items']['rename_link'] = $variables['element']['rename_link'];
unset($variables['element']['rename_link']);
}
}
/**
* Add 'show rename link' setting to widget settings.
*
......@@ -169,8 +139,10 @@ function file_rename_file_prerename(FileInterface $file) {
* @param array $form
* Current form.
*
* @return mixed
* Processed render element.
* @todo Multiple file field is not fully supported yet.
* On remove one of the files the Rename button disappears.
* See: https://www.drupal.org/project/drupal/issues/3177977
*
*/
function _file_rename_widget_custom_process(array $element, FormStateInterface $form_state, array $form) {
$parents_prefix = implode('_', $element['#parents']);
......@@ -186,7 +158,7 @@ function _file_rename_widget_custom_process(array $element, FormStateInterface $
->getPathInfo();
}
$file_id = $element['#default_value']['target_id'];
$element['rename_link'] = [
$element['file_' . $file_id]['rename_link'] = [
'#name' => $parents_prefix . '_rename_link',
'#type' => 'link',
'#title' => t('Rename'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment