Problem/Motivation

Since Content templates 1.3.0, the "Create content from this template" form is served by the module-specific route content_templates.node.quick_clone at /template/{node}/quick_clone.

When the Gin administration theme is used, this route is not recognized as a content form. As a result, Gin does not apply its content form enhancements to this clone form.

The fields and actions that should be displayed in Gin's content form layout are rendered in the main node form instead. In particular, the fields that should appear in the Gin meta sidebar are displayed inline in the form, and the sticky action bar, the "More actions" toggle, and the meta sidebar toggle are missing.

The normal node edit form continues to work correctly, so the issue is limited to the clone form used when creating content from a template.

This issue was introduced when #3526579: Clone vs template UI labels

Steps to reproduce

  1. Install Content templates 1.3.0.
  2. Install and enable the Gin administration theme.
  3. Create a content template from an existing node.
  4. Use the "Create content from this template" action.
  5. Confirm that the form opens at /template/{node}/quick_clone.
  6. Observe that the Gin sticky action bar is not displayed.
  7. Observe that the "More actions" toggle is not displayed.
  8. Observe that the meta sidebar toggle is not displayed.
  9. Compare with the normal node edit form, where these Gin controls are displayed correctly.

Proposed resolution

Add Content templates clone route to Gin's content form route list by implementing hook_gin_content_form_routes().

The patch adds a new OOP hook method, ginContentFormRoutes(), to src/Hook/ContentTemplatesHooks.php. This method returns the route name content_templates.node.quick_clone, allowing Gin to recognize the "Create content from this template" clone form as a content form.

The patch also adds a procedural wrapper in content_templates.module using #[LegacyHook]. This keeps the implementation compatible with the module's existing hook style and with Drupal versions where hook attributes are ignored.

This uses Gin's official extension point and does not add Gin as a hard dependency. The hook is only invoked by Gin when Gin is installed and active.

Once the route is registered, Gin can apply its normal content form behavior to this form, restoring the sticky action bar, the "More actions" toggle, and the meta sidebar toggle.

Remaining tasks

Review the merge request.

User interface changes

The patch restores existing Gin user interface behavior on the "Create content from this template" clone form. When Gin is active, the sticky action bar, the "More actions" toggle, and the meta sidebar toggle are displayed again.

API changes

None.

Data model changes

None.

CommentFileSizeAuthor
#5 3605909_after.png425.58 KBcsakiistvan
#5 3605909_before.png282.22 KBcsakiistvan
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

lolgm created an issue. See original summary.

lolgm’s picture

Status: Active » Needs review

MR !12 implements the proposed solution in this issue.

csakiistvan’s picture

Assigned: Unassigned » csakiistvan
csakiistvan’s picture

StatusFileSize
new282.22 KB
new425.58 KB

## Environment
- Drupal: 11.3.13
- PHP: 8.5.5
- Database: MariaDB 10.11.16
- DDEV: v1.25.2
- Content templates: 1.3.0
- Gin: 4.0.x-dev
- Browser: Chrome

## Prerequisites
- Gin is the admin theme (`system.theme:admin` = `gin`).
- Install and enable the module (pulls in media and quick_node_clone):
- `ddev composer require drupal/content_templates:1.3.0`
- `ddev drush en content_templates -y`
- A content template built from an existing node, so its clone form is reachable:
```bash
ddev drush php-eval '
$t = \Drupal::entityTypeManager()->getStorage("content_template")->create([
"name" => "My template", "status" => 1, "field_source" => 4,
]);
$t->save();'
```
(Replace `4` with any existing node id.)

## Root cause
Since Content templates 1.3.0 the clone form is served by the module route `content_templates.node.quick_clone` (`/template/{node}/quick_clone`). Gin recognises content forms in two places: its form alter (which has the form state and detects the node form) and its HTML preprocess (which only has the route name). The HTML preprocess only knows a fixed route list plus routes registered via `hook_gin_content_form_routes()`. Because the module route was not registered, the `gin--edit-form` body class was not added on the clone form, so Gin's content-form layout (meta sidebar placement) was not applied even though the sticky action bar markup was.

## Steps
1. Apply the fix from MR !12: register `content_templates.node.quick_clone` with Gin by implementing `hook_gin_content_form_routes()` (OOP hook in `src/Hook/ContentTemplatesHooks.php` plus a `#[LegacyHook]` procedural wrapper in `content_templates.module`).
2. Rebuild caches: `ddev drush cr`
3. Log in as an administrator and open `/template/4/quick_clone`.
4. Compare with the normal node edit form at `/node/4/edit`.

## Expected results
- The clone form uses Gin's content-form layout: the meta fields (author, revision log, menu settings, URL alias, authoring information) appear in the right-hand meta sidebar, and the meta sidebar toggle works.
- Behaviour matches the normal node edit form and the quick_node_clone form at `/clone/{node}/quick_clone`.

## Actual results
Before the fix, `/template/4/quick_clone` was missing the `gin--edit-form` body class, so Gin's edit-form layout was not applied: the meta fields (author, URL alias, authoring information, etc.) rendered inline at the bottom of the form and the meta sidebar toggle was absent, while the equivalent `/clone/{node}/quick_clone` route (already in Gin's list) rendered correctly. After registering the route via the hook, the `gin--edit-form` class is present on the clone form and the meta fields render in the right-hand sidebar, matching the normal node edit form.

---

*Testing produced with the assistance of an LLM.*

csakiistvan’s picture

Assigned: csakiistvan » Unassigned
Status: Needs review » Reviewed & tested by the community

a.dmitriiev made their first commit to this issue’s fork.

a.dmitriiev’s picture

Category: Feature request » Bug report

Thank you for fixes and review. Please next time check also coding standards.

a.dmitriiev’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

csakiistvan’s picture

> Please next time check also coding standards.

Good point, i will check it Artem