Created
October 19, 2012 02:25
-
-
Save pen/3915913 to your computer and use it in GitHub Desktop.
sample style for Amon2 CRUD actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MyApp::PC::Admin::Member; | |
use 5.016; | |
use warnings; | |
my @RULE = ( | |
name => ['NOT_NULL'], | |
); | |
sub edit { | |
my ($class, $c) = @_; | |
my $member = $c->db->single('members', +{ id => $c->req->param('member_id') }) | |
or return $c->redirect('/member/?error'); | |
given {$c->req->method)) { | |
when ('GET') { | |
$c->fillin_form($member->get_columns); | |
} | |
when ('POST') { | |
$c->fillin_form($c->req); | |
my $params = $c->validator->check(@RULE) | |
or break; | |
$member->update($params); | |
$c->jq->dispatch('OtherSystem.notify', $member->get_columns); | |
return $c->redirect('/member/'); | |
} | |
} | |
return $c->render('member/edit.tx'); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment