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 explanations regarding form submissions and the data-turbo attribute for Flash Messages #2486

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/Turbo/doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,26 @@ situation.
]
]);


4. Flash Messages and forward-fetching side effects
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Of course, if you have side effects, like added `Flash Messages <https://symfony.com/doc/current/session.html#flash-messages>`_
to your form submissions, they will be flushed during the asynchronous call.
To prevent such actions on form submissions to be executed ahead of time
(like emptying a FlashBag of session messages), the best way is
to simply disable Turbo Drive on submission inputs/buttons
(which are tried on hover by default).

Simply add a ``data-turbo="false"`` attribute and value to your widgets:

.. code-block:: html

<button data-turbo="false">Submit form</button>

This way, only your real user manual action will trigger the form submission.
More information can be found in the Turbo documentation: https://turbo.hotwired.dev/reference/attributes.

More Turbo Drive Info
^^^^^^^^^^^^^^^^^^^^^

Expand Down
Loading