Changeset 17
- Timestamp:
- 03/07/09 18:44:50 (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Vote/Controller/Ballot.pm
r16 r17 59 59 $c->stash->{choices} = { %choices }; 60 60 $c->stash->{sbal} = { map { $_ => 1 } $c->req->param('sbal') }; 61 $c->stash->{fsbal} = [ map { 62 s/^\s+//; 63 s/\s+$//; 64 s/\s+/ /g; 65 $_ 66 } ($c->req->param('fsbal')) ]; 67 68 my @torecord = grep { $_ } ( 69 (map { $choices{$_} } $c->req->param('sbal')), 70 @{ $c->stash->{fsbal} } 71 ); 72 73 warn $vote->vote_info($id)->{choice_count}; 74 warn scalar(@torecord); 75 warn $_ foreach(@torecord); 76 if (scalar(@torecord) > $vote->vote_info($id)->{choice_count}) { 77 $c->req->param('ballot', ''); 78 $c->stash->{vote_error} = 'Seulement ' . 79 $vote->vote_info($id)->{choice_count} . ' choix possible'; 80 return; 81 } 61 82 62 83 if ($c->req->param('confirm')) { … … 64 85 $uid, 65 86 $id, 66 [ grep { $_ } ( 67 map { $choices{$_} } $c->req->param('sbal'), 68 $c->req->param('fsbal'), 69 ) ], 87 [ @torecord ], 70 88 $c->req->address, 71 89 ); # TODO trap error -
trunk/root/templates/ballot/default.tt
r15 r17 1 1 [% vote = c.model('Vote') %] 2 2 3 [% INLCUDE 'includes/poll.tt' %] 3 [% thisvote = vote.vote_info(voteid) %] 4 5 [% INCLUDE 'includes/poll.tt' %] 4 6 5 7 [% IF c.req.param('ballot') %] … … 13 15 [% FOREACH ch = c.req.param('fsbal') %] 14 16 [% ch | html %]<br> 15 <input type="hidden" name=" sbal" value="[% ch %]">17 <input type="hidden" name="fsbal" value="[% ch %]"> 16 18 [% END %] 17 19 <input type="submit" name="confirm"> … … 20 22 21 23 [% ELSE %] 24 25 [% IF vote_error %][% vote_error %][% END %] 22 26 23 27 <form action="[% c.uri_for(voteid) %]"> … … 30 34 [% count = 0 %] 31 35 [% WHILE count < thisvote.free_choice %] 32 <input type="text" name="fsbal" value="[% c.req.param('fsbal').count %]"><br>36 <input type="text" name="fsbal" value="[% fsbal.$count %]"><br> 33 37 [% count = count + 1 %] 34 38 [% END %]
Note: See TracChangeset
for help on using the changeset viewer.