Use init form template settings as fallback for corrupted data
[MAILPOET-3924]
This commit is contained in:
committed by
Veljko V
parent
7da2304c4d
commit
dfc4c286df
@ -211,11 +211,7 @@ class FormEditor {
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'create') {
|
||||
$this->createForm();
|
||||
}
|
||||
$form = Form::findOne((int)$_GET['id']);
|
||||
if ($form instanceof Form) {
|
||||
$form = $form->asArray();
|
||||
}
|
||||
$form['styles'] = $this->formRenderer->getCustomStyles($form);
|
||||
$form = $this->getFormData((int)$_GET['id']);
|
||||
$customFields = $this->customFieldsRepository->findAll();
|
||||
$dateTypes = $this->dateBlock->getDateTypes();
|
||||
$data = [
|
||||
@ -337,6 +333,21 @@ class FormEditor {
|
||||
return $translations;
|
||||
}
|
||||
|
||||
private function getFormData(int $id) {
|
||||
$form = Form::findOne($id);
|
||||
if (!$form instanceof Form) {
|
||||
return null;
|
||||
}
|
||||
$form = $form->asArray();
|
||||
$form['styles'] = $this->formRenderer->getCustomStyles($form);
|
||||
// Use empty settings in case they are corrupted or missing
|
||||
if (!is_array($form['settings'])) {
|
||||
$initialFormTemplate = $this->templatesRepository->getFormTemplate(TemplateRepository::INITIAL_FORM_TEMPLATE);
|
||||
$form['settings'] = $initialFormTemplate->getSettings();
|
||||
}
|
||||
return $form;
|
||||
}
|
||||
|
||||
private function getAllPosts() {
|
||||
global $wpdb;
|
||||
$optionList = $wpdb->get_results('SELECT ID, post_title FROM ' . $wpdb->posts . " WHERE post_type='post'");
|
||||
|
Reference in New Issue
Block a user