1 package Apache::MVC::Model::CDBI;
2 use base 'Apache::MVC::Model::Base';
3 use Class::DBI::AsForm;
4 use Class::DBI::FromCGI;
7 sub description { "A poorly defined class" }
9 sub column_names { my $class = shift; map { $_ => ucfirst $_ } $class->columns }
11 sub do_edit :Exported {
13 my $h = CGI::Untaint->new(%{$r->{params}});
16 # We have something to edit
17 $obj = $self->retrieve($r->{args}[0]);
18 $obj->update_from_cgi($h);
19 warn "Updating an object ($obj) with ".Dumper($h); use Data::Dumper;
21 $obj = $self->create_from_cgi($h);
23 if (my %errors = $obj->cgi_update_errors) {
24 # Set it up as it was:
25 warn "There were errors: ".Dumper(\%errors)."\n";
26 $r->{template_args}{cgi_params} = \%params;
27 $r->{template_args}{errors} = \%errors;
28 $r->{template} = "edit";
30 $r->{template} = "view";
36 my ($self, $child) = @_;
37 $child->autoupdate(1);
38 $child->columns( Stringify => qw/ name / );