Skip to content

Commit

Permalink
Revert "testing lazy computing of fif"
Browse files Browse the repository at this point in the history
This was a mistake.

This reverts commit cc86a29.
  • Loading branch information
Zbigniew Lukasiak committed May 1, 2009
1 parent cc86a29 commit c45da61
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 27 deletions.
34 changes: 15 additions & 19 deletions lib/HTML/FormHandler/Field.pm
Expand Up @@ -128,6 +128,13 @@ has 'value' => (
is => 'rw',
clearer => 'clear_value',
predicate => 'has_value',
trigger => sub {
my ( $self, $value ) = @_;
$self->fif( $self->fif_value($value) )
unless ( ( $self->password && $self->password == 1 )
|| $self->has_fields );
return $value;
}
);

=head2 parent
Expand Down Expand Up @@ -164,6 +171,12 @@ has 'input' => (
is => 'rw',
clearer => 'clear_input',
predicate => 'has_input',
trigger => sub {
my ( $self, $input ) = @_;
$self->fif($input)
unless ( $self->password && $self->password == 1 );
return $input;
}
);

=head2 input_without_param
Expand All @@ -189,24 +202,7 @@ input parameters. The normal use would be to access this field from a template:
=cut

has 'fif' => (
is => 'rw',
clearer => 'clear_fif',
predicate => 'has_fif',
lazy_build => 1,
);

sub _build_fif {
my $self = shift;
return if( defined $self->password && $self->password == 1 );
if( defined $self->input ){
return $self->input;
}
if( defined $self->value ){
return $self->value;
}
return;
}
has 'fif' => ( is => 'rw', clearer => 'clear_fif', predicate => 'has_fif' );

=head2 accessor
Expand Down Expand Up @@ -885,7 +881,7 @@ sub process

$field->_apply_actions;

# $field->_build_fif if $field->can('_build_fif');
$field->_build_fif if $field->can('_build_fif');
return if $field->has_errors;
return unless $field->validate;
return unless $field->test_ranges;
Expand Down
1 change: 0 additions & 1 deletion lib/HTML/FormHandler/Model/DBIC.pm
Expand Up @@ -437,7 +437,6 @@ sub init_value
}
$field->init_value($value);
$field->value($value);
$field->fif($value);
}

sub _fix_value
Expand Down
5 changes: 2 additions & 3 deletions t/fif.t
Expand Up @@ -66,9 +66,7 @@ ok( !$form->field('author')->has_input, 'no input for field');

$form->clear_state;
ok( !$form->fif, 'clear_state clears fif' );
warn $form->field('author')->value;
warn $form->field('author')->input;
warn Dumper( $form->fif ); use Data::Dumper;


my $params = {
title => 'Testing form',
Expand All @@ -77,6 +75,7 @@ my $params = {
author => 'J.Doe',
publisher => '',
};

$form = BookDB::Form::Book->new(item => $book, schema => $schema, params => $params);

$validated = $form->validate( $params );
Expand Down
4 changes: 2 additions & 2 deletions t/filters.t
Expand Up @@ -109,7 +109,7 @@ is( ref $form->field('date_coercion_pass')->value, 'DateTime', 'values coerced
ok( $form->field('date_coercion_error')->has_errors, 'DateTime coercion error' );
my ( $message ) = $form->field('date_coercion_error')->errors;
is( $message, 'This is not a correct date', 'Error message for coercion' );
#$params->{coerce_pass} = '10';
#$params->{sprintf_filter} = '<1e+02>';
$params->{coerce_pass} = '10';
$params->{sprintf_filter} = '<1e+02>';
is_deeply( $form->fif, $params, 'fif is correct' );

3 changes: 1 addition & 2 deletions t/password.t
Expand Up @@ -29,12 +29,11 @@ is( $field->password, undef, 'password is not set');

$field->value('abcdef');
is( $field->value, 'abcdef', 'set and get value' );

is( $field->fif, 'abcdef', 'get fif');

$field->clear_fif;
$field->value(undef);
is( $field->fif, undef, 'get undef fif' );

$field->clear_fif;
$field->input('xyz');
is( $field->fif, 'xyz', 'get fif from input');

0 comments on commit c45da61

Please sign in to comment.