From 709b412bf72084e48d408787d8455f9876fcdaed Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 18 Aug 2020 19:35:29 +0200 Subject: [PATCH] Toggling preview button is only possible before building form See #3513 --- .../container/wysiwyg/WysiwygFormContainer.class.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php index 08267cbf73..aa097ca3eb 100644 --- a/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php +++ b/wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php @@ -218,11 +218,16 @@ class WysiwygFormContainer extends FormContainer { * * By default, the preview button is shown. * - * @param bool $enablePreviewButton - * @return WysiwygFormContainer this form container + * @param bool $enablePreviewButton + * @return WysiwygFormContainer this form container * @since 5.3 + * @throws \BadMethodCallException if the form field container has already been populated yet */ public function enablePreviewButton($enablePreviewButton = true) { + if ($this->isPopulated) { + throw new \BadMethodCallException('Enabling and disabling the preview button is only possible the form has been built.'); + } + $this->enablePreviewButton = $enablePreviewButton; return $this; -- 2.20.1