feat: forms on TYPO3 13, loaded into the static pages with htmx
The static export replaced every EXT:form form with a contact notice. The forms are back, rendered by TYPO3 13 and embedded in the static pages: - Page type 1704 (/<page>/form) renders only the form plugin of a page, inside a .form-island element. Every form posts to that URL (renderingOptions.additionalParams), because on www the page URL is a static file that never reaches TYPO3. htmx swaps the island in place: validation errors, multi-step pages and confirmations. A redirect to an htmx request becomes HX-Redirect (HtmxRedirectMiddleware), so Redirect finishers send the browser to the thank-you page. - While a request runs, an overlay with a spinner (as in MyE&P) covers the form. Styled inside the island: the static pages load the CSS of the TYPO3 10 export. - The bw_captcha image comes from /<page>/captcha for the same reason. Both suffixes are in the PageType enhancer of every site with forms (semesterende gets one with default '' to keep its URLs). - Ported from TYPO3 10: form setup, templates and partials, the MyE&P address finisher, the job application finisher with the MyE&P Team API client (epTeamApi* in secrets.php), the page URL/referrer finisher with ReferrerMiddleware (?ref=), the e-mail layout without the system footer, bw_captcha 5 and form_element_linked_checkbox 6. The address check forms are dropped. - German language packs (EXT:form messages): availableLanguages = de, fetched on every deploy (typo3:language:update). - The checkbox partials passed null to VHS' substring, which PHP 8.5 reports as deprecated. - DDEV no longer turns deprecations into exceptions, matching production: EXT:form's RenderFormValueViewHelper uses null as an array offset for empty optional fields (core bug, also in 13.4.37). The static pages get their placeholders from the exporter in EP/website, see .ddev/plans/static-export-form-islands.patch (local only). Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
59e4a2d49b
commit
925e24397b
54 files changed
+2500
-3
No files matched your search
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace EP\EpTheme\Form;
|
||||
|
||||
use EP\EpTheme\Middleware\ReferrerMiddleware;
|
||||
use TYPO3\CMS\Core\Routing\PageArguments;
|
||||
use TYPO3\CMS\Core\Site\Entity\Site;
|
||||
use TYPO3\CMS\Form\Domain\Finishers\AbstractFinisher;
|
||||
use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication;
|
||||
|
||||
/**
|
||||
* Adds the URL of the form's page and, if known, the page the visitor came from (see
|
||||
* ReferrerMiddleware) to the submission, so the e-mail finishers include them.
|
||||
*/
|
||||
class AddReferrerFinisher extends AbstractFinisher
|
||||
{
|
||||
protected function executeInternal()
|
||||
{
|
||||
$this->addCurrentUrlField();
|
||||
$this->addReferrerField();
|
||||
}
|
||||
|
||||
private function addReferrerField(): void
|
||||
{
|
||||
$frontendUser = $this->finisherContext->getRequest()->getAttribute('frontend.user');
|
||||
if (!$frontendUser instanceof FrontendUserAuthentication) {
|
||||
return;
|
||||
}
|
||||
|
||||
$referrer = $frontendUser->getKey('ses', ReferrerMiddleware::SESSION_KEY);
|
||||
if (null === $referrer) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->addField('referrer', 'Referrer', $referrer);
|
||||
|
||||
$frontendUser->setKey('ses', ReferrerMiddleware::SESSION_KEY, null);
|
||||
$frontendUser->storeSessionData();
|
||||
}
|
||||
|
||||
private function addCurrentUrlField(): void
|
||||
{
|
||||
$request = $this->finisherContext->getRequest();
|
||||
$routing = $request->getAttribute('routing');
|
||||
$site = $request->getAttribute('site');
|
||||
if (!$routing instanceof PageArguments || !$site instanceof Site) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The page itself, not the form page type the submission was posted to
|
||||
$url = (string)$site->getRouter()->generateUri($routing->getPageId(), [
|
||||
'_language' => $request->getAttribute('language'),
|
||||
]);
|
||||
$this->addField('pageurl', 'URL', $url);
|
||||
}
|
||||
|
||||
private function addField(string $identifier, string $label, string $value): void
|
||||
{
|
||||
$field = $this->finisherContext
|
||||
->getFormRuntime()
|
||||
->getFormDefinition()
|
||||
->getPageByIndex(0)
|
||||
->createElement($identifier, 'Text');
|
||||
|
||||
$field->setDefaultValue($value);
|
||||
$field->setDataType('string');
|
||||
$field->setLabel($label);
|
||||
|
||||
// Finisher variable for potential later use
|
||||
$this->finisherContext->getFinisherVariableProvider()->add(
|
||||
$this->shortFinisherIdentifier,
|
||||
$identifier,
|
||||
$value
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user