*/
protected $attachmentData;
+ /**
+ * `true` if the preview button should be shown and `false` otherwise
+ * @var bool
+ * @since 5.3
+ */
+ protected $enablePreviewButton = true;
+
/**
* name of the relevant message object type
* @var string
return $this;
}
+ /**
+ * Sets whether the preview button should be shown or not and returns this form container.
+ *
+ * By default, the preview button is shown.
+ *
+ * @param bool $enablePreviewButton
+ * @return WysiwygFormContainer this form container
+ * @since 5.3
+ */
+ public function enablePreviewButton($enablePreviewButton = true) {
+ $this->enablePreviewButton = $enablePreviewButton;
+
+ return $this;
+ }
+
/**
* Returns the form field handling attachments.
*
return $this->required;
}
+ /**
+ * Returns `true` if the preview button will be shown and returns `false` otherwise.
+ *
+ * By default, the preview button is shown.
+ *
+ * @return bool
+ * @since 5.3
+ */
+ public function isPreviewButtonEnabled() {
+ return $this->enablePreviewButton;
+ }
+
/**
* @since 5.3
* @inheritDoc
$this->setAttachmentHandler();
}
- $this->getDocument()->addButton(
- WysiwygPreviewFormButton::create($this->getWysiwygId() . 'PreviewButton')
- ->objectType($this->messageObjectType)
- ->wysiwygId($this->getWysiwygId())
- ->objectId($this->getObjectId())
- );
+ if ($this->enablePreviewButton) {
+ $this->getDocument()->addButton(
+ WysiwygPreviewFormButton::create($this->getWysiwygId() . 'PreviewButton')
+ ->objectType($this->messageObjectType)
+ ->wysiwygId($this->getWysiwygId())
+ ->objectId($this->getObjectId())
+ );
+ }
EventHandler::getInstance()->fireAction($this, 'populate');
}