add form submission handling and confirmation emails
Validate form submissions and action configuration, execute finishers with submission context, and return JSON success or error responses. Add configurable confirmation emails to submitters and report failed submissions in the form UI. Harden database and admin email finishers, and add submission handler and confirmation email checks.
This commit is contained in:
@@ -1,22 +1,10 @@
|
||||
<?php
|
||||
|
||||
$formsRepository = new \Plugi\Extensions\Form\DefinitionsRepository();
|
||||
$handler = new \Plugi\Extensions\Form\SubmissionHandler();
|
||||
$result = $handler->handle($_GET['id'] ?? null, file_get_contents('php://input') ?: '');
|
||||
|
||||
$form = $formsRepository->findWithId($_GET['id']);
|
||||
$formFinishers = json_decode($form['finishers'], true);
|
||||
|
||||
$finishers = new \Plugi\Extensions\Form\Finishers\FinishersRepository();
|
||||
|
||||
|
||||
|
||||
foreach ($formFinishers as $finisher) {
|
||||
if ($finishers->finisherExists($finisher['type'])) {
|
||||
$config = $finishers->getFinisherConfig($finisher['type']);
|
||||
$instance = new $config['class'];
|
||||
$instance->execute();
|
||||
}
|
||||
}
|
||||
|
||||
phpb_redirect('/', [], 201);
|
||||
http_response_code($result['status']);
|
||||
header('Content-Type: application/json; charset=utf-8');
|
||||
echo json_encode($result['body'], JSON_UNESCAPED_UNICODE | JSON_INVALID_UTF8_SUBSTITUTE);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user