innomedio / sulu-form-landing-page-bundle
在表单提交成功后在 Sulu 表单中定义重定向。
v3.0.1
2024-08-26 10:56 UTC
Requires
- ext-curl: *
- ext-json: *
- jackalope/jackalope-doctrine-dbal: ^2.0
- sulu/sulu: ^2.5
- symfony/framework-bundle: ^6.1 || ^7.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpro/grumphp: ^1.3
- phpstan/phpstan: ^0.12.85 || ^1.4
README
由于 Sulu 核心团队尚未确定实现表单着陆页的最佳方式,我们创建了一个简单的解决方案。
安装
使用 composer 安装
composer require innomedio/sulu-form-landing-page-bundle
如果未自动添加,将捆绑包添加到 config/bundles.php
Innomedio\Sulu\FormLandingPageBundle\InnomedioSuluFormLandingPageBundle::class => ['all' => true],
用法
现在您可以定义成功提交表单的重定向 URL。您还可以定义需要附加的查询字符串。
{{ form_start(content.testForm) }}
<input type="hidden" name="_sulu_form_redirect" value="{{ sulu_content_load(content.landingPage).path }}" />
<input type="hidden" name="_sulu_form_querystring" value="?utm=this&id=that" />
{{ form_end(content.testForm) }}
因此现在您可以创建一个内容块,包含 single_page_selection 和 single_form_selection 字段,以便能够动态处理表单重定向。
还有可用的辅助模板
{% include '@InnomedioSuluFormLandingPage/sulu_redirect_form.html.twig' with {
form: content.testForm,
redirect: sulu_content_load(content.landingPage).path,
querystring: '?utm=this&id=that'
} %}