]> git.decadent.org.uk Git - maypole.git/blob - ex/fancy_example/BeerDB/Base.pm
Drinker uses add_to_from_cgi and other stuff. Now it is a nice working
[maypole.git] / ex / fancy_example / BeerDB / Base.pm
1 package BeerDB::Base;
2 use base qw/Maypole::Model::CDBI/;
3 use strict;
4 use warnings;
5
6 # Overide list to add display_columns to cgi  
7 # Perhaps do this in AsForm?
8
9 sub list : Exported {
10         use Data::Dumper;
11         my ($self, $r) = @_;
12         $self->SUPER::list($r);
13         my %cols =  map { $_ => 1 } $self->columns, $self->display_columns;
14         my @cols = keys %cols;
15         $r->template_args->{classmetadata}{cgi} = { $self->to_cgi(@cols) }; 
16 }
17
18
19 # Template switcheroo bug bit me -- was seeing view page but the view action was never 
20 # being executed after an edit.
21 sub do_edit : Exported {
22         my ($self, $r) = (shift, shift);
23         $self->SUPER::do_edit($r, @_);
24         if (my $obj = $r->object) {
25                 my $url = $r->config->uri_base . "/" . $r->table . "/view/" . $obj->id;
26                 $r->redirect_request(url => $url);
27         }
28 }
29
30 sub metadata: Exported {}
31         
32
33 1;