Skip to content

Commit

Permalink
Cleanup verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Feb 4, 2009
1 parent e6e15b9 commit eb26e31
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 28 deletions.
6 changes: 6 additions & 0 deletions Changes
@@ -1,5 +1,11 @@
Revision history for HTML::FormHandler Revision history for HTML::FormHandler


0.12 Wed Feb 04 2009, 18:00
Fix 'dump_fields'. Add more output for verbose. Change so
that 'validate' doesn't require a separate 'clear' for
persistent forms. The controller test will only execute
with an environment variable.

0.11 Mon Feb 02 2009, 17:00 0.11 Mon Feb 02 2009, 17:00
Change to use BEGIN block in controllers for Catalyst 5.80. Change to use BEGIN block in controllers for Catalyst 5.80.


Expand Down
1 change: 0 additions & 1 deletion META.yml
Expand Up @@ -4,7 +4,6 @@ author:
- 'Gerda Shank, gshank@cpan.org' - 'Gerda Shank, gshank@cpan.org'
build_requires: build_requires:
Test::More: 0.77 Test::More: 0.77
Test::WWW::Mechanize: 1.24
distribution_type: module distribution_type: module
generated_by: 'Module::Install version 0.77' generated_by: 'Module::Install version 0.77'
license: perl license: perl
Expand Down
2 changes: 0 additions & 2 deletions Makefile.PL
Expand Up @@ -16,8 +16,6 @@ requires 'DateTime';
requires 'DBIx::Class'; requires 'DBIx::Class';
requires 'HTML::Entities'; requires 'HTML::Entities';


test_requires 'Test::WWW::Mechanize' => '1.24';

recommends 'Catalyst'; recommends 'Catalyst';
recommends 'Catalyst::Component::InstancePerContext'; recommends 'Catalyst::Component::InstancePerContext';
recommends 'Template'; recommends 'Template';
Expand Down
36 changes: 21 additions & 15 deletions lib/HTML/FormHandler.pm
Expand Up @@ -57,7 +57,12 @@ to update a 'Book' record:
$c->res->redirect( $c->uri_for('list') ); $c->res->redirect( $c->uri_for('list') );
} }
The example above has the forms as a persistent part of the application.
If you prefer, it also works fine to create the form on each request:
my $form = MyApp::Form->new;
my $validated = $form->process( item => $book, params => $params );
An example of a form class: An example of a form class:
package MyApp::Form::User; package MyApp::Form::User;
Expand Down Expand Up @@ -349,18 +354,6 @@ has 'field_counter' => (
default => 1 default => 1
); );


=head2 name_prefix
You don't need this attribute unless you have a compound field.
Prefix used for field names in compound fields. The collection
of fields can be a complete form. An example might be a field
that represents a DateTime object, but is made up of separate
day, month, and year fields.
=cut

has 'name_prefix' => ( isa => 'Str', is => 'rw' );

=head2 html_prefix =head2 html_prefix
Flag to indicate that the form name is used as a prefix for fields Flag to indicate that the form name is used as a prefix for fields
Expand All @@ -379,6 +372,19 @@ will return the form name + "." + field name


has 'html_prefix' => ( isa => 'Bool', is => 'rw' ); has 'html_prefix' => ( isa => 'Bool', is => 'rw' );


=head2 name_prefix
You don't need this attribute unless you have a compound field.
Prefix is used for field names in compound fields. The collection
of fields can be a complete form. An example might be a field
that represents a DateTime object, but is made up of separate
day, month, and year fields. Adds the 'name_prefix' plus a dot to
the beginning of the field name.
=cut

has 'name_prefix' => ( isa => 'Str', is => 'rw' );

=head2 active_column =head2 active_column
The column in tables used for select list that marks an option 'active' The column in tables used for select list that marks an option 'active'
Expand Down Expand Up @@ -725,11 +731,12 @@ sub dump_fields
{ {
my $self = shift; my $self = shift;


warn "HFH: Fields for form ", $self->name, "\n"; warn "HFH: ------- fields for form ", $self->name, "-------\n";
for my $field ( $self->sorted_fields ) for my $field ( $self->sorted_fields )
{ {
$field->dump; $field->dump;
} }
warn "HFH: ------- end fields -------\n";
} }


=head2 init_from_object =head2 init_from_object
Expand Down Expand Up @@ -1113,7 +1120,6 @@ sub build_form
{ {
my $self = shift; my $self = shift;


warn "HFH: build_form\n" if $self->verbose;
my $meta_flist = $self->meta->field_list if $self->meta->can('field_list'); my $meta_flist = $self->meta->field_list if $self->meta->can('field_list');
my $flist = $self->field_list; my $flist = $self->field_list;
$self->_build_fields( $meta_flist, 0 ) if $meta_flist; $self->_build_fields( $meta_flist, 0 ) if $meta_flist;
Expand Down
18 changes: 9 additions & 9 deletions lib/HTML/FormHandler/Field.pm
Expand Up @@ -901,23 +901,23 @@ sub dump
my $self = shift; my $self = shift;


require Data::Dumper; require Data::Dumper;
warn "HFH: **** Field: ", $self->name, "\n"; warn "HFH: ----- ", $self->name, " -----\n";
warn "HFH: Field Type: ", ref($self), "\n"; warn "HFH: type: ", ref($self), "\n";
warn "HFH: Required: ", ( $self->required || '0' ), "\n"; warn "HFH: required: ", ( $self->required || '0' ), "\n";
warn "HFH: Password: ", ( $self->password || '0' ), "\n"; warn "HFH: password: ", ( $self->password || '0' ), "\n";
my $v = $self->value; my $v = $self->value;
warn "HFH: Value: ", Data::Dumper::Dumper $v if $v; warn "HFH: value: ", Data::Dumper::Dumper $v if $v;
my $iv = $self->init_value; my $iv = $self->init_value;
warn "HFH: InitValue: ", Data::Dumper::Dumper $iv if $iv; warn "HFH: init_value: ", Data::Dumper::Dumper $iv if $iv;
my $i = $self->input; my $i = $self->input;
warn "HFH: Input: ", Data::Dumper::Dumper $i if $i; warn "HFH: input: ", Data::Dumper::Dumper $i if $i;
my $fif = $self->fif; my $fif = $self->fif;
warn "HFH: Fif: ", Data::Dumper::Dumper $fif if $fif; warn "HFH: fif: ", Data::Dumper::Dumper $fif if $fif;


if ( $self->can('options') ) if ( $self->can('options') )
{ {
my $o = $self->options; my $o = $self->options;
warn "HFH: Options: " . Data::Dumper::Dumper $o; warn "HFH: options: " . Data::Dumper::Dumper $o;
} }
} }


Expand Down
2 changes: 1 addition & 1 deletion t/lib/BookDB/Controller/Book.pm
Expand Up @@ -9,7 +9,7 @@ use BookDB::Form::Book;
use BookDB::Form::BookView; use BookDB::Form::BookView;


has 'edit_form' => ( isa => 'BookDB::Form::Book', is => 'rw', has 'edit_form' => ( isa => 'BookDB::Form::Book', is => 'rw',
lazy => 1, default => sub { BookDB::Form::Book->new } ); lazy => 1, default => sub { BookDB::Form::Book->new( verbose => 1 ) } );
has 'view_form' => ( isa => 'BookDB::Form::BookView', is => 'rw', has 'view_form' => ( isa => 'BookDB::Form::BookView', is => 'rw',
lazy => 1, default => sub { BookDB::Form::BookView->new } ); lazy => 1, default => sub { BookDB::Form::BookView->new } );


Expand Down

0 comments on commit eb26e31

Please sign in to comment.