Hi,

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...

Can someone please help me ? Thanks  :)


  post '/enreg' => sub {
    my $c = shift;

    my $validation = $c->validation;
    return $c->render unless $validation->has_data;

    $validation->required('mo')->like(qr/^\d*\.?\d*$/)->minimum(0);
    $validation->required('z_1')->like(qr/^\d+$/)->range(5, 250);
    
    my $mots = $c->session('mots');
    
    for (my $i=2 ; $i<=$mots ; $i++) {
      my $j = $i-1;
      $validation->required('cusse_' . $j . '_' . 
$i)->like(qr/^\d*\.?\d*$/);
      $validation->required('z_' . $i)->like(qr/^\d+$/)->range(5, 250);
    }
    
    return $c->render('derns', mots => $mots) if $validation->has_error;
    
    if (not $validation->has_error) {

      ...
      
      my $error = suite_roues(\%r);
      if ($error) { $c->flash(error_message => "Il n'y a pas de solution au 
problème tel que vous l'avez posé.", aide => 1) ; return 
$c->render('derns', mots => $mots) }
    }
    $c->redirect_to('vueprincipale');
  }

@@ derns.html.ep
% layout 'default';

%= form_for enreg => begin
  ...
  %= submit_button 'OK'
% end

% if (my $err_msg = flash 'error_message') {
  <br><font color="red"><b><%= $err_msg %></b></font><br><br>
% }
%= link_to Déconnexion => 'logout'

-- 
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.

Reply via email to