Modal doesn't have Save submit button on Edit on Gin admin theme

Created on 8 October 2024, 3 months ago

Problem/Motivation

We need to add a Submit button to save override content

Steps to reproduce

1) Installed the module.
2) Created the field.
3) Add the media file via the Media Library
4) Press Edit

Proposed resolution

Fix the bug

πŸ› Bug report
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine Foxy-vikvik

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Foxy-vikvik
  • πŸ‡ΊπŸ‡¦Ukraine Foxy-vikvik

    FYI using admin theme Claro - works fine

  • πŸ‡§πŸ‡ͺBelgium StryKaizer Belgium

    When using GIN + layout builder, this is a known issue.

    A fix for this is to implement hook_form_alter in a custom module, and do something like this.

    PS: we have a lot of form ids in the $gin_lb_form_ids variable, e.g. entity browser ids, media edit forms (if you use that module, ...)
    This code will ensure all those forms use the actual gin css.

      // Get active theme
      $theme = \Drupal::theme()->getActiveTheme()->getName();
      if ($theme != 'gin') {
        // Enable gin_lb theming for custom frontent forms too.
        $gin_lb_form_ids = [
          'override_entity_form',
        ];
        if (in_array($form_id, $gin_lb_form_ids)) {
          $form['#after_build'][] = [
            'Drupal\gin_lb\HookHandler\FormAlter',
            'afterBuildAttachGinLbForm',
          ];
          $form['#gin_lb_form'] = TRUE;
          $form['#attributes']['class'][] = 'glb-form';
          unset($form["revision_information"]);
          unset($form["revision_log_message"]);
          unset($form["revision"]);
          unset($form["revision_log"]);
        }
      }
    
  • πŸ‡§πŸ‡ͺBelgium StryKaizer Belgium
  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    We've got this issue. Been faffing with the code above, doesn't seem to work. Also doesn't really capture folks using gin as a base theme? Also just not sure about that first conditional of if the theme IS NOT gin? Without comments or a link to another issue I'm guessing at exactly what it's trying to resolve.

    Here's our modified version that checks if it is GIN or a GIN sub theme, but for us isn't working. Even skipping the initial theme check (where you went != and I went == or in array) it does not seem to resolve the issue.

    // ATTEMPT TO FIX GIN LB OVERRIDE ENTITY FORM MISSING SUBMIT BUTTON!
      $theme = \Drupal::theme()->getActiveTheme()->getName();
      $base_themes = array_keys(\Drupal::theme()->getActiveTheme()->getBaseThemeExtensions());
      if (
        $theme == 'gin'
        || in_array('gin', $base_themes)
      ) {
        // Enable gin_lb theming for custom frontend! forms too.
        $gin_lb_form_ids = [
          'override_entity_form',
        ];
        if (in_array($form_id, $gin_lb_form_ids)) {
          $form['#after_build'][] = [
            'Drupal\gin_lb\HookHandler\FormAlter',
            'afterBuildAttachGinLbForm',
          ];
          $form['#gin_lb_form'] = TRUE;
          $form['#attributes']['class'][] = 'glb-form';
          unset($form["revision_information"]);
          unset($form["revision_log_message"]);
          unset($form["revision"]);
          unset($form["revision_log"]);
        }
      }
  • πŸ‡ΊπŸ‡¦Ukraine Foxy-vikvik

    I am working on a project where we use Gin + Paragraphs, and your code does not work for me.

  • πŸ‡§πŸ‡ͺBelgium StryKaizer Belgium

    @jnicola

    Also just not sure about that first conditional of if the theme IS NOT gin?

    As said, my code is a fix for users using layout builder (which is rendered in frontend theme).

    If you experience this issue in the backend, my code snippet will not help you ;)

  • πŸ‡©πŸ‡ͺGermany a.dmitriiev

    For me updating to Gin 3.0.0-rc14 fixed the problem. The "Save" button appeared at the bottom of the modal window.

  • πŸ‡ΊπŸ‡ΈUnited States jnicola

    Double check that the save button is there and that it actually saves. Our problem is that we can get the Save button back using a related patch for Gin, but unfortunately the submission does not succeed with no ajax error nor drupal log error.

Production build 0.71.5 2024