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:
2026-11-24 11:26:37 +01:00
parent 80e60d6823
commit c507618b90
10 changed files with 593 additions and 47 deletions
+5 -17
View File
@@ -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);