Class-DBI-AsForm-2.42/ 0000755 0001752 0001752 00000000000 10307413457 013043 5 ustar tony tony Class-DBI-AsForm-2.42/t/ 0000755 0001752 0001752 00000000000 10307413457 013306 5 ustar tony tony Class-DBI-AsForm-2.42/t/01.t 0000644 0001752 0001752 00000002723 10307413227 013712 0 ustar tony tony package Foo;
use Test::More;
eval "require DBD::SQLite" or plan skip_all => "Couldn't load DBD::SQLite";
plan tests => 4;
package DBI::Test;
use base 'Class::DBI';
BEGIN { unlink 'test.db'; };
DBI::Test->set_db("Main", "dbi:SQLite:dbname=test.db");
DBI::Test->db_Main->do("CREATE TABLE foo (
id integer not null primary key,
bar integer,
baz varchar(255)
);");
DBI::Test->db_Main->do("CREATE TABLE bar (
id integer not null primary key,
test varchar(255)
);");
DBI::Test->table("test");
package Bar;
use base 'DBI::Test';
Bar->table("bar");
Bar->columns(All => qw/id test/);
Bar->columns(Stringify => qw/test/);
sub retrieve_all {
bless { test => "Hi", id => 1}, shift;
}
package Foo;
use base 'DBI::Test';
Foo->table("foo");
use_ok("Class::DBI::AsForm");
no warnings 'once';
$Class::DBI::AsForm::OLD_STYLE=1;
*type_of = sub { "varchar" };
Foo->columns(All => qw/id bar baz/);
like(Foo->to_field("baz"), qr/has_a(bar => Bar);
is(Foo->to_field("bar"), "\n",
"Select OK");
my $x = bless({id => 1, bar => Bar->retrieve_all(), baz => "Hello there"}, "Foo");
my %cgi = ( id => '
',
bar => '
',
baz => '
'
);
is_deeply({$x->to_cgi}, \%cgi, "All correct as an object method");
Class-DBI-AsForm-2.42/t/pod.t 0000644 0001752 0001752 00000000201 10307412534 014241 0 ustar tony tony use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();
Class-DBI-AsForm-2.42/t/pod-coverage.t 0000644 0001752 0001752 00000000241 10307412534 016036 0 ustar tony tony use Test::More;
eval "use Test::Pod::Coverage 1.00";
plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
all_pod_coverage_ok();
Class-DBI-AsForm-2.42/lib/ 0000755 0001752 0001752 00000000000 10307413457 013611 5 ustar tony tony Class-DBI-AsForm-2.42/lib/Class/ 0000755 0001752 0001752 00000000000 10307413457 014656 5 ustar tony tony Class-DBI-AsForm-2.42/lib/Class/DBI/ 0000755 0001752 0001752 00000000000 10307413457 015254 5 ustar tony tony Class-DBI-AsForm-2.42/lib/Class/DBI/AsForm.pm 0000644 0001752 0001752 00000010305 10307413432 016771 0 ustar tony tony package Class::DBI::AsForm;
use 5.006;
our $VERSION = '2.42';
use strict;
use warnings;
use base 'Exporter';
use Class::DBI::Plugin::Type ();
use HTML::Element;
our $OLD_STYLE = 0;
our @EXPORT = qw( to_cgi to_field _to_textarea _to_textfield _to_select
type_of );
=head1 NAME
Class::DBI::AsForm - Produce HTML form elements for database columns
=head1 SYNOPSIS
package Music::CD;
use Class::DBI::AsForm;
use base 'Class::DBI';
use CGI;
...
sub create_or_edit {
my $class = shift;
my %cgi_field = $class->to_cgi;
return start_form,
(map { "$_: ". $cgi_field{$_}->as_HTML."
" }
$class->Columns),
end_form;
}
#