Create a new form from template

[MAILPOET-2987]
This commit is contained in:
Pavel Dohnal
2020-06-22 15:25:33 +02:00
committed by Veljko V
parent a2ff7a34db
commit 07637c69cf
2 changed files with 141 additions and 127 deletions

View File

@ -5,6 +5,13 @@ namespace MailPoet\Form;
use MailPoet\Models\Form;
class FormFactory {
public function createFormFromTemplate(array $template) {
if (isset($template['id'])) {
unset($template['id']);
}
return Form::createOrUpdate($template);
}
/** @return Form */
public function createEmptyForm() {
$data = [
@ -42,6 +49,6 @@ class FormFactory {
'segments_selected_by' => 'admin',
],
];
return Form::createOrUpdate($data);
return $this->createFormFromTemplate($data);
}
}