Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot save inline elements on a Subsite in some circumstances #628

Open
2 tasks done
wernerkrauss opened this issue Jan 22, 2025 · 0 comments
Open
2 tasks done

Cannot save inline elements on a Subsite in some circumstances #628

wernerkrauss opened this issue Jan 22, 2025 · 0 comments

Comments

@wernerkrauss
Copy link
Contributor

wernerkrauss commented Jan 22, 2025

Module version(s) affected

5.3.6

Description

Silverstripe 5.3.0, Elemental 5.3.6, Subsites 3.3.0

When I have a page on a Subsite (not Main) and there is a Page on Main with the same ID like my Element, I cannot save, cause LeftAndMainSubsites extensions wants to redirect to that page on Main.

Saving works when not inline editable or with any element with an ID that does not fit to an ID of a Page on Main.

How to reproduce

Make a new project with SS5, Elemental, Subsites.

Create a new subsite

Create a Page on the new Subsite and an Element. The Element should have e.g. ID1 which corresponds to a Page on Main

Try to save; check network tab in webdev; it returns a 200 and a blank response; in the answer of the request should be a redirect like

X-Controller | DNADesign\Elemental\Controllers\ElementalAreaController
X-Controllerurl | admin/elemental-area/show/2?SubsiteID=0

Possible Solution

To fix this nasty bug, I added the following configuration:

#hacky fix for getting elemental to work with subsites
DNADesign\Elemental\Controllers\ElementalAreaController:
  tree_class: DNADesign\Elemental\Models\BaseElement

This makes CMSMain controller getRecord() look for an Element instead of a Page

Note: Another possibility (maybe even cleaner) would be to overwrite getRecord() in ElementalAreaController...

Additional Context

CC to @adiwidjaja

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@GuySartorelli GuySartorelli transferred this issue from silverstripe/silverstripe-elemental Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants