Changeset 110


Ignore:
Timestamp:
03/26/09 16:24:31 (15 years ago)
Author:
nanardon
Message:
  • show values detected as submited twice (#15)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Vote/Controller/Ballot.pm

    r88 r110  
    8282    $c->request->parameters->{fsbal} = $c->stash->{fsbal}; 
    8383 
    84     my @sbalval = grep { $_ } map { $choices{$_} } $c->req->param('sbal'); 
     84    my @sbalval = grep { $_ } map { lc($choices{$_} || '') } $c->req->param('sbal'); 
    8585 
    8686    if (scalar(@sbalval) + scalar(@{$c->stash->{fsbal} || []}) 
     
    9393    { 
    9494        my %uniq; 
    95         $uniq{lc($_)} = 1 foreach(@sbalval, @{$c->stash->{fsbal} || []}); 
    96         if (scalar(keys %uniq) != scalar(@sbalval) + scalar(@{$c->stash->{fsbal} || []})) { 
     95        foreach(@sbalval, @{$c->stash->{fsbal} || []}) { 
     96            $uniq{lc($_)} ||= 0; # avoid undef 
     97            $uniq{lc($_)}++; 
     98        } 
     99        my @twices = grep { $uniq{$_} > 1 } (sort keys %uniq); 
     100        if (scalar(@twices)) { 
    97101            $c->req->parameters->{'ballot'} = ''; 
    98             $c->stash->{vote_error} = 'Une valeur est en double'; 
     102            $c->stash->{vote_error} = 'Une ou plusieurs valeurs sont en double: ' . 
     103                join(' ,', map { qq'"$_"' } @twices); 
    99104            return; 
    100105        } 
Note: See TracChangeset for help on using the changeset viewer.