Skip to content

Commit

Permalink
a crud base controller api improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Zbigniew Lukasiak committed Apr 21, 2010
1 parent b497675 commit 270f168
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/WebNano/Controller/CRUD.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ use Class::MOP;
extends 'WebNano::Controller';
with 'WebNano::Controller::CodeAttributesForMeta';

has record_controller_class => ( is => 'ro', isa => 'Str', );
has form_class => ( is => 'ro', isa => 'Str' );
has rs_name => ( is => 'ro', isa => 'Str' );

around 'handle' => sub {
my( $orig, $self, @args ) = @_;

Expand All @@ -25,6 +29,7 @@ around 'handle' => sub {
request => $self->request,
self_url => $self->self_url . "$id/",
record => $record,
form_class => $self->form_class,
);
return $new_controller->handle( @args );
}
Expand All @@ -43,9 +48,7 @@ sub create : Action {
my $req = $self->request;

my $form_class = $self->form_class;
warn $form_class;
Class::MOP::load_class( $form_class );
warn 'aaaaaaaaa';
my $form = $form_class->new(
params => $req->params,
schema => $self->application->schema,
Expand All @@ -70,6 +73,8 @@ sub create : Action {
extends 'WebNano::Controller';
with 'WebNano::Controller::CodeAttributesForMeta';

has form_class => ( is => 'ro', isa => 'Str' );

has record => ( isa => 'DBIx::Class::Row', is => 'ro' );

sub index : Action {
Expand Down Expand Up @@ -102,16 +107,11 @@ sub create : Action {
my $self = shift;
my $req = $self->request;
my $form_class = $self->form_class;
warn $form_class;
Class::MOP::load_class( $form_class );
warn 'aaaaaaa';
warn ref $self->record;
$DB::single = 1;
my $form = $form_class->new(
item => $self->record,
params => $req->params,
);
warn 'bbbbbb';
if( $req->method eq 'POST' && $form->process() ){
my $res = $req->new_response();
$res->redirect( $self->self_url . '/view' );
Expand Down

0 comments on commit 270f168

Please sign in to comment.