Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add form ID to redirect on successful submission #92

Open
matt-halliday opened this issue Aug 3, 2017 · 3 comments
Open

Add form ID to redirect on successful submission #92

matt-halliday opened this issue Aug 3, 2017 · 3 comments
Labels

Comments

@matt-halliday
Copy link

matt-halliday commented Aug 3, 2017

Q A
Bug? no
New Feature? yes
SuluFormBundle Version dev-feature/symfony-3-release
Sulu Version 1.6.2

Actual Behavior

On success, the page is redirected to /some-path?send=true

Desired Behavior

On success, the page is redirected to /some-path?send=true&form=<ID of form>. This will allow developers to have more than one form on a page (i.e. in content blocks) and handle displaying success messages when only one is filled out.

Possible Solutions

Sulu\Bundle\FormBundle\Event\RequestListener.php line 105

$response = new RedirectResponse('?send=true&form=' . $dynamic->getForm()->getId());

Not sure if this is the cleanest method given the resulting twig nonsense:

{% if app.request.get('send') == 'true' and app.request.get('form') == block.form.children['formId'].vars.data %}
     {{ view_component.form.entity.successText|raw }}
{% else %}
    {% form_theme block.form 'form/themes/dynamic.html.twig' %}
    {{ form(block.form) }}
{% endif %}

Basically some way of identifying which form has been submitted.

@alexander-schranz
Copy link
Member

@matt-halliday currently there are also some other problems as you cant display the data in the backend on that page so its currently not possible to have forms inside blocks #63.

@matt-halliday
Copy link
Author

matt-halliday commented Aug 3, 2017

@alexander-schranz ok - seems to be working just fine for me - which data do you mean? The submissions to the form are showing in the data tab of the forms themselves.

The only thing I had to do was pass some extra data from the view component in with the block to get the success message:

{% for i, block in content.blocks %}
    {% include 'blocks/'  ~ block.type ~  '/' ~ block.type ~ '.html.twig' with {
        "block": block,
        "view_component": view.blocks[i]
    } %}
{% endfor %}

@alexander-schranz
Copy link
Member

alexander-schranz commented Aug 3, 2017

its possible to have a tab of the data on the page itself this is currently not possible as the Tab dont know where the search for the form id when the form is part of the block. With 0.2 there where some issues solved but its not 100% ready for be used in blocks (#63) also your issue with the success message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants