[Catalyst-commits] r8441 - in trunk/Catalyst-Example-InstantCRUD:
lib/Catalyst/Example/Controller t
zby at dev.catalyst.perl.org
zby at dev.catalyst.perl.org
Wed Sep 24 07:52:33 BST 2008
Author: zby
Date: 2008-09-24 07:52:33 +0100 (Wed, 24 Sep 2008)
New Revision: 8441
Modified:
trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm
trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t
Log:
OO interface for RHF::DBIC
Modified: trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm 2008-09-22 19:59:15 UTC (rev 8440)
+++ trunk/Catalyst-Example-InstantCRUD/lib/Catalyst/Example/Controller/InstantCRUD.pm 2008-09-24 06:52:33 UTC (rev 8441)
@@ -7,23 +7,15 @@
use Carp;
use Data::Dumper;
use Path::Class;
-use Rose::HTMLx::Form::DBIC qw/ dbic_from_form options_from_resultset init_with_dbic /;
+use Rose::HTMLx::Form::DBIC;
use version; our $VERSION = qv('0.0.12');
sub auto : Local {
my ( $self, $c ) = @_;
- $c->stash->{additional_template_paths} = [ dir( $c->config->{root}, $self->source_name) . '', $c->config->{root} . ''];
+ $c->stash->{additional_template_paths} = [ dir( $c->config->{root}, lc $self->source_name) . '', $c->config->{root} . ''];
}
-sub load_interface_config {
- my ( $self, $c ) = @_;
- my $cfile = file( dir( $c->config->{root} )->parent, 'interface_config.dat' );
- my $tmp = do $cfile;
- my $class = $self->source_name;
- return $tmp->{$self->source_name};
-}
-
sub source_name {
my $self = shift;
my $class = ref $self;
@@ -74,24 +66,21 @@
my $form_name = ref( $self ) . '::' . $self->source_name . 'Form';
my $form = $form_name->new();
my $rs = $self->model_resultset($c);
- options_from_resultset( $form, $rs );
+ my $processor = Rose::HTMLx::Form::DBIC->new( form => $form, rs => $rs );
my $params = $c->req->params;
- $form->params( $params );
-# $form->prepare();
- $form->init_fields();
+ $processor->init_params( $params );
if( $c->req->method eq 'POST' and $form->was_submitted ){
- if ( $form->validate ){
- my $item = dbic_from_form($form, $rs, @pks);
+ if( my $item = $processor->dbic_from_form(@pks) ){
$c->res->redirect( $c->uri_for( 'view', $item->id ) );
+ $c->stash( item => $item );
}
}
else {
- init_with_dbic($form, $rs->find( @pks, { key => 'primary' } ) ) if scalar @pks;
+ $processor->init_from_dbic(@pks) if scalar @pks;
}
$c->stash( form => $form );
}
-
sub view : Local {
my ( $self, $c, @pks ) = @_;
die "You need to pass an id" unless @pks;
Modified: trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t
===================================================================
--- trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t 2008-09-22 19:59:15 UTC (rev 8440)
+++ trunk/Catalyst-Example-InstantCRUD/t/10.apptest.t 2008-09-24 06:52:33 UTC (rev 8441)
@@ -12,7 +12,7 @@
if ($@){
plan skip_all => "Test::WWW::Mechanize::Catalyst required for testing application";
}else{
- plan tests => 14;
+ plan tests => 20;
}
my $mech = Test::WWW::Mechanize::Catalyst->new;
More information about the Catalyst-commits
mailing list