innomedio/sulu-form-landing-page-bundle

Define redirects in Sulu forms after a successful form submit.

v1.0.2 2021-09-01 06:47 UTC

This package is auto-updated.

Last update: 2021-12-31 00:23:45 UTC


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'
} %}