The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
package BookDB::Form::Book;

use strict;
use warnings;
use base 'Form::Processor::Model::DBIC';

=head1 NAME

Form object for the Book Controller

=head1 SYNOPSIS

Form used for book/add and book/edit actions

=head1 DESCRIPTION

Catalyst Form.

=cut

sub object_class { 'DB::Book' }

sub profile {
	my $self = shift;

	return {
		auto_required => ['title', 'author', 'isbn', 'publisher'],
        auto_optional => ['books_genres', 'format', 'year', 'pages'], 
		unique => ['isbn'],
	};
}

# The following subroutine makes the same select list as
# the one that's created by accessing the database
#sub options_format {
#	return (
#        1 => 'Paperback',
#        2 => 'Hardcover',
#		 3 => 'Comic',
#	);
#}


sub validate_year {
	my ( $self, $field ) = @_;
	$field->add_error('Invalid year')
	     if (($field->value > 3000) || ($field->value < 1600));
};


=head1 AUTHOR

Gerda Shank

=head1 LICENSE AND COPYRIGHT

This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.

=cut

1;