Allow preview for unsaved forms
[MAILPOET-3662]
This commit is contained in:
@ -155,10 +155,8 @@ class Forms extends APIEndpoint {
|
||||
}
|
||||
|
||||
public function previewEditor($data = []) {
|
||||
$formId = $data['id'] ?? null;
|
||||
if (!$formId) {
|
||||
$this->badRequest();
|
||||
}
|
||||
// We want to allow preview for unsaved forms
|
||||
$formId = $data['id'] ?? 0;
|
||||
$this->wp->setTransient(PreviewPage::PREVIEW_DATA_TRANSIENT_PREFIX . $formId, $data, PreviewPage::PREVIEW_DATA_EXPIRATION);
|
||||
return $this->successResponse();
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class FormPreview {
|
||||
}
|
||||
|
||||
public function renderContent(): string {
|
||||
if (!isset($this->data['id']) || !isset($this->data['form_type'])) {
|
||||
if (!array_key_exists('id', $this->data ?? []) || !isset($this->data['form_type'])) {
|
||||
return '';
|
||||
}
|
||||
return $this->formPreviewPage->renderPage(
|
||||
|
Reference in New Issue
Block a user