innomedio / sulu-form-landing-page-bundle
Define redirects in Sulu forms after a successful form submit.
Installs: 1 196
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/innomedio/sulu-form-landing-page-bundle
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
Since the Sulu core team is not sure yet about the best way to implement landing pages for forms we've created a simple workaround.
Installation
Install using composer:
composer require innomedio/sulu-form-landing-page-bundle
Add the bundle to config/bundles.php if it's not automatically added:
Innomedio\Sulu\FormLandingPageBundle\InnomedioSuluFormLandingPageBundle::class => ['all' => true],  
Usage
You can now define the redirect url for successfully submitted forms. You can also define a querystring that needs to be appended.
{{ 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) }}
So now you could create a content block containing a single_page_selection and single_form_selection field to be able to dynamically handle form redirects.
There's also a helper template available:
{% include '@InnomedioSuluFormLandingPage/sulu_redirect_form.html.twig' with {
    form: content.testForm,
    redirect: sulu_content_load(content.landingPage).path,
    querystring: '?utm=this&id=that'
} %}