From ad995ee2e9be3c2dd9ad2b1fc8ed385bdeda1e19 Mon Sep 17 00:00:00 2001 From: Andreas Fernandez <a.fernandez@scripting-base.de> Date: Mon, 10 Feb 2020 09:29:42 +0100 Subject: [PATCH] [BUGFIX] Check correctly for existing click event With #90238 the JavaScript function `goToalt_doc` is registered as a Fluid variable. However, the check for an existing event in the template broke as the variable now always has a value. To fix the situation, a new boolean variable `hasClickEvent` is introduced. Resolves: #90344 Related: #90238 Releases: master, 9.5 Change-Id: I7d86d300be923db82a0f79c3dd479a708230d92d Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63185 Reviewed-by: Claus Due <claus@phpmind.net> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Richard Haeser <richard@maxserv.com> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Tested-by: Richard Haeser <richard@maxserv.com> --- .../ContentElement/NewContentElementController.php | 5 ++++- .../Resources/Private/Templates/NewContentElement/Main.html | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php index 07e42e8ff3e0..d0867a5ab663 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/NewContentElementController.php @@ -266,7 +266,10 @@ class NewContentElementController $cc = ($key = 0); $menuItems = []; - $this->view->assign('onClickEvent', 'function goToalt_doc() { ' . $this->onClickEvent . '}'); + $this->view->assignMultiple([ + 'hasClickEvent' => $this->onClickEvent !== '', + 'onClickEvent' => 'function goToalt_doc() { ' . $this->onClickEvent . '}', + ]); foreach ($wizardItems as $wizardKey => $wInfo) { $wizardOnClick = ''; diff --git a/typo3/sysext/backend/Resources/Private/Templates/NewContentElement/Main.html b/typo3/sysext/backend/Resources/Private/Templates/NewContentElement/Main.html index ef12a94890e5..713f7fa2855a 100644 --- a/typo3/sysext/backend/Resources/Private/Templates/NewContentElement/Main.html +++ b/typo3/sysext/backend/Resources/Private/Templates/NewContentElement/Main.html @@ -3,7 +3,7 @@ <f:then> <f:form action="" name="editForm" id="NewContentElementController"> <f:form.hidden name="defValues" value="" /> - <f:if condition="{onClickEvent}"> + <f:if condition="{hasClickEvent}"> <f:then> <script> {onClickEvent -> f:format.raw()} -- GitLab