use Class::DBI::AsForm;
use Class::DBI::FromCGI;
use CGI::Untaint;
+use strict;
sub description { "A poorly defined class" }
if (my %errors = $obj->cgi_update_errors) {
# Set it up as it was:
warn "There were errors: ".Dumper(\%errors)."\n";
- $r->{template_args}{cgi_params} = \%params;
+ $r->{template_args}{cgi_params} = $r->{params};
$r->{template_args}{errors} = \%errors;
$r->{template} = "edit";
} else {
$child->columns( Stringify => qw/ name / );
}
+sub search :Exported {
+ my ($self, $r) = @_;
+ my %fields = map {$_ => 1 } $self->columns;
+ my %values = map { $_ => $params{$_} }
+ grep { $params{$_} and $fields{$_} } keys %{$r->{params}};
+ $r->objects([ %values ? $self->search_like(%values) : $self->retrieve_all ]);
+ $r->template("list");
+ $r->{template_args}{search} = 1;
+}
+
+
1;
[% INCLUDE header %]
+[% IF search %]
+<h2> Search results </h2>
+[% ELSE %]
<h2> Listing of all [% classmetadata.plural %]</h2>
+[% END %]
[% INCLUDE navbar %]
<DIV class="search"> [% INCLUDE search_form %] </DIV>