Toggling preview button is only possible before building form
authorMatthias Schmidt <gravatronics@live.com>
Tue, 18 Aug 2020 17:35:29 +0000 (19:35 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Tue, 18 Aug 2020 17:35:29 +0000 (19:35 +0200)
See #3513

wcfsetup/install/files/lib/system/form/builder/container/wysiwyg/WysiwygFormContainer.class.php

index 08267cbf731c32ac2c9e919008d010ab01063106..aa097ca3eb2621575791fd3a56e86f4215113984 100644 (file)
@@ -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;