Skip to content

Instantly share code, notes, and snippets.

@pen
Created October 19, 2012 02:25
Show Gist options
  • Save pen/3915913 to your computer and use it in GitHub Desktop.
Save pen/3915913 to your computer and use it in GitHub Desktop.
sample style for Amon2 CRUD actions
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