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

Event storage-action gives result "success" although form throws error #69

Closed
mprofitl opened this Issue Apr 14, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@mprofitl

mprofitl commented Apr 14, 2018

My form has a couple of obligatory fields. The form correctly throws an error when one of them is not filled in. When the form succeeds storage should be dropped, when the form throws an error no storage-action should be taken. I added therefore the storage-action filter to my event and a hidden field as described on Github. The storage-action event however succeeds also when the form fails.

Thanks for you hints on how to solve this
Regards – Moritz

Symphony 2.7.4
Storage extension 1.6.4

That's the line I added as described in the manual:
<input type="hidden" name="storage-action[drop][warenkorb]" value="1" />

Here is the XML I get when posting the form with a missing field:

<events>
    <bestellung-senden result="error">
        <message message-id="102">Beim Speichern des Eintrags sind Fehler aufgetreten.</message>
        <name label="Name" type="missing" message-id="301" message="‚Name‘ ist ein Pflichtfeld." />
        <post-values>
            <firma>profitlich.</firma>
            <telefonnummer>078 846 65 32</telefonnummer>
            <e-mailadresse>moritz@profitlich.ch</e-mailadresse>
            <bestellung-nur-text>XYZ</bestellung-nur-text>
            <bestellung-html>XYZ</bestellung-html>
            <adresse-merken>yes</adresse-merken>
            <datum-und-zeit>2018-04-14-13:39</datum-und-zeit>
            <sprache>de</sprache>
        </post-values>
    </bestellung-senden>
    <storage-action type="drop" result="success">
        <request-values />
    </storage-action>
</events>
@michael-e

This comment has been minimized.

Owner

michael-e commented Apr 15, 2018

Thanks for the precise description of your issue.

I am using the same setup, and it works perfectly for me. (When saving fails, the filter is not triggered, nor is the filter node included in the event repsonse.) Additionally I verified that Symphony (2.6.11, in my case) only executes such "final save" filters if an event has been sucessful.

Which version of Symphony is it? And is there any "hack" or "exotic extension" which might be responsible for this?

@mprofitl

This comment has been minimized.

mprofitl commented Apr 18, 2018

I found out what I did wrong: When using the event filter, the event must not be added to the page. If the event is added, the event filter will be ignored and the action will be executed in all cases. Maybe you could add this to the documentation.

After finding this out I am confused: What is the event for? On the same page I have two more forms that feed storage by Ajax. They still work without the event added, just by using a hidden field:
<input type="hidden" name="storage-action[set]" />

Best regards and thanks for the quick reply you sent

@michael-e

This comment has been minimized.

Owner

michael-e commented Apr 19, 2018

Oh, the events are intended to work like all other events in Symphony, they are triggered on page load. So the idea is to attach them to pages, for example an order confirmation page — so you can delete the "storage" when the confirmation page is loaded.

So the difference is:

  • Events are always triggered on page load.
  • Filters are attached to an "unrelated" event (e.g. a "save" event) and are triggered only if the event has been executed successful.

Since Storage events and Storage filters use the same field names, the idea is to use only one of these.

@michael-e

This comment has been minimized.

Owner

michael-e commented Apr 19, 2018

Maybe you could add this to the documentation.

I'll take a look.

michael-e added a commit that referenced this issue Apr 20, 2018

@michael-e

This comment has been minimized.

Owner

michael-e commented Apr 20, 2018

I added this to the README.

@michael-e michael-e closed this Apr 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment