Gin is overriding title on custom entity forms

Created on 24 April 2024, 7 months 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 Clara 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 for 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

Active

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.71.5 2024