Create a new form for the user

[MAILPOET-1798]
This commit is contained in:
Pavel Dohnal
2020-02-10 11:02:37 +01:00
committed by Jack Kitterhing
parent 3443f082ef
commit 0fd954184d
7 changed files with 82 additions and 40 deletions

45
lib/Form/FormFactory.php Normal file
View File

@ -0,0 +1,45 @@
<?php
namespace MailPoet\Form;
use MailPoet\Models\Form;
class FormFactory {
/** @return Form */
public function createEmptyForm() {
$data = [
'name' => '',
'body' => [
[
'id' => 'email',
'name' => __('Email', 'mailpoet'),
'type' => 'text',
'static' => true,
'params' => [
'label' => __('Email', 'mailpoet'),
'required' => true,
'label_within' => true,
],
],
[
'id' => 'submit',
'name' => __('Submit', 'mailpoet'),
'type' => 'submit',
'static' => true,
'params' => [
'label' => __('Subscribe!', 'mailpoet'),
],
],
],
'settings' => [
'on_success' => 'message',
'success_message' => Form::getDefaultSuccessMessage(),
'segments' => null,
'segments_selected_by' => 'admin',
],
];
return Form::createOrUpdate($data);
}
}