On Sun, May 7, 2017 at 5:45 AM, <[email protected]> wrote: > Something strange happens to me for a flash message. > > Have a form, and when this one is correctly filled and the user clic on > ok, a calculation is done. > > Depending of the result on this, I have to stay on the form and put an > (error) flash message to the user. > > In this last case, nothing happens on the first clic on ok (the use stays > on the same form, no message). > > The message is displayed on the second clic... >
>From flash <http://mojolicious.org/perldoc/Mojolicious/Controller#flash>: Data storage persistent only for the *next* request, stored in the "session" <http://mojolicious.org/perldoc/Mojolicious/Controller#session>. Also notice how the documentation shows pairing it with "redirect_to" (a next request). Rendering, as you're doing, isn't a next request, the rendering is happening on *this* request. So rather than flash, I think you just want to stash. ... if ($error) { return $c->render('derns', mots => $mots, error_message => "Il n'y a pas ...", aide => 1) } ... @@ derns.html.ep ... % if (my $err_msg = stash 'error_message') { ... Now, if you want an error message to show when you redirect_to("vueprincipale") then you'd want to flash. $c->flash(error => 'message')->redirect_to('vueprincipale'); ... @@ vueprincipale.html.ep ... if (my $err_msg = flash 'error') { ... -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
