Gin is overriding title on custom entity forms

Created on 24 April 2024, about 2 months ago
Updated 14 May 2024, about 1 month ago

Problem/Motivation

I couldnโ€™t find this issue in the queue so so Iโ€™m opening this. If anyone knows of this issue please feel free to close this.

In the access policy module Iโ€™ve created my own entity form. In that entity form Iโ€™ve have a confirmation step asking users if they want to change the access policy.

In the Claro theme it looks like this.

In Gin it looks like this:

Technical Details

I've created a new form that specifies the title with #title. (Note that code has been removed for brevity).

  protected function buildConfirmForm(array &$form, FormStateInterface $form_state) {
    $form['#title'] = $this->t('Are you sure you want to set access to Public?');
  }

This is respected by Seven, Claro etc but gets overwritten by gin here:

gin/page.theme

function gin_preprocess_page_title(&$variables) {
 if (preg_match('/entity\.node\..*/', \Drupal::routeMatch()->getRouteName(), $matches)) {
    $node = \Drupal::routeMatch()->getParameter('node');
    $node = \Drupal::service('entity.repository')->getActive('node', $node->id());
    if ($node instanceof Node) {
      if ($node->isDefaultTranslation() && !in_array($matches[0], [
        'entity.node.content_translation_add',
        'entity.node.delete_form',
      ])) {
        // This is overwriting the title provided in #title. 
        $variables['title'] = $node->getTitle();
      }
      // ... Code removed for brevity ...
      }
    }
  }
}

Proposed resolution

I couldn't quite understand why this was being done, perhaps we could remove it or find an alternate approach? This was introduced as part of https://www.drupal.org/project/gin/issues/3275704 โ†’ though that code seemed secondary to the original intent of that ticket.

      if ($node->isDefaultTranslation() && !in_array($matches[0], [
        'entity.node.content_translation_add',
        'entity.node.delete_form',
      ])) {
        $variables['title'] = $node->getTitle();
      }
๐Ÿ› Bug report
Status

Needs review

Version

3.0

Component

Code

Created by

๐Ÿ‡บ๐Ÿ‡ธUnited States partdigital

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

Merge Requests

Comments & Activities

Production build 0.69.0 2024