perlron has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks,

I am not able to correctly process a list of error fields returned from my form validator. Even if three fields fail the required validation, only 1 field eg- s_tel is getting printed in the markup. The results from FormValidator are accurate and all three fields are getting retrieved.(confirmed with logging statements)
any advice would be great !


TT code in template file
[% IF error_list %] [% FOREACH i IN error_list %] [% i %] | [% END %] [% END %]
Code in CGI_Application module
my $input_profile = { required => [qw( s_addr s_tel s_adv01)] }; my $results = Data::FormValidator->check(\%validation_params,$inpu +t_profile); my %ret_params = ( 'error_list' => $results->missing); if($results->has_invalid or $results->has_missing){ return $self->tt_process('school_register.tt',\%ret_params); }

Replies are listed 'Best First'.
Re: List Data in TT and CGI_Application
by Loops (Curate) on Oct 17, 2014 at 19:51 UTC

    The context is wrong when assigning your return params hash. Think the following should fix it up:

    my %ret_params = ( 'error_list' => scalar $results->missing );

    The relevant documentation: Missing says you need scalar context to get a reference to the array of missing fields.

      it worked . absolutely. thanks!