FIX: Prevent frontend JS/CSS from loading in CMS admin context#1432
FIX: Prevent frontend JS/CSS from loading in CMS admin context#1432lerni wants to merge 1 commit intosilverstripe:7.0from
Conversation
When ElementFormController triggers UserDefinedFormController::init() in the CMS (e.g. via elemental block rendering), frontend resources like jQuery are loaded and overwrite the admin's jQuery with entwine attached, causing a cascade of JS errors ($.entwine is not a function). Add a LeftAndMain guard to skip frontend Requirements in admin context. CMS-side userforms UI (userforms-cms.js) is unaffected as it loads through getCMSFields() paths.
| If there's an issue for this, can you please link to it? Otherwise please make a new issue and link to that instead. This is part of the PR template and is important because the tools we use to track contributions are good when tracking issues but aren't great for tracking PRs. Please also check all the boxes in the checklist that apply - the checklist is there so you can make sure the PR is in a good state prior to being reviewed. If you think you shouldn't check a box that's usually an indication that more work is needed. |
| Root cause was custom code in my project calling ElementalArea::forTemplate() during a CMS request 🙈 Fixed on my end. Sorry for the noiz. Closing since the standard elemental code doesn't trigger this path in CMS context, though the guard could still be useful defensively. |
Description
When ElementFormController triggers
UserDefinedFormController::init()in the CMS (e.g. via elemental block rendering), frontend resources like jQuery are loaded and overwrite the admin's jQuery with entwine attached, causing a cascade of JS errors ($.entwine is not a function).Add a LeftAndMain guard to skip frontend Requirements in admin context. CMS-side userforms UI (userforms-cms.js) is unaffected as it loads through getCMSFields() paths.
Steps to reproduce
dnadesign/silverstripe-elemental-userformsElementFormblock to any pageblock_default_userforms_js: falsein config (needed for frontend display rules)$.entwine is not a function,tooltip is not a function, etc.Workaround (without this fix)
Setting
block_default_userforms_js: trueprevents the issue but also blocks display rules JS on the frontend.Pull request checklist