Skip Menu |

This queue is for tickets about the CGI-Ex CPAN distribution.

Report information
The Basics
Id: 19881
Status: resolved
Priority: 0/
Queue: CGI-Ex

People
Owner: Nobody in particular
Requestors: charlieb [...] budge.apana.org.au
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: 2.02



Subject: Multiple probs in cgi_ex_2.cgi
I've needed to make a few changes to get the example to run. -use base CGI::Ex::App; +use base 'CGI::Ex::App'; - push @$path, 'userinfo'; +$self->append_path('userinfo'); +$self->set_ready_validate(0); Now in order to make the form labels visible, I've needed to comment out the colors: - color => ['#ccf', '#aaf'], + #color => ['#ccf', '#aaf'], I just get black bars otherwise. Finally I get this crash when I submit the form (without JS): [Tue Jun 13 11:51:34 2006] [error] [client 192.168.58.1] Step userinfo: Missing field key during normal validation at /usr/lib/perl5/site_perl/5.8.5/CGI/Ex/Validate.pm line 145., referer: http://192.168.58.128/cgi-bin/index.cgi [Tue Jun 13 11:51:34 2006] [error] [client 192.168.58.1] Premature end of script headers: index.cgi, referer: http://192.168.58.128/cgi-bin/index.cgi
"form_name" also seens to be ignored by generate_js(): ... $hash->{form_name} = 'formfoo'; $hash->{js_val} = $self->vob->generate_js($self->userinfo_hash_validation(), $hash->{form_name}, ); but the generated js contains: ... if (document.check_form) document.check_form("theform"); ... which causes an alert on loading, and a failure to validate anything.
Here's Data::Dumper of $fields at line 137: $VAR1 = [, {, field => "username",, match => "m/^\\\\w+\\$/",, max_len => 30,, min_len => 3,, required => 1, },, {, field => "password",, max_len => 20,, required => 1, },, {, equals => "password",, validate_if => "password", }, ];, and sure enough there is no "field" in the conditional equals validation. The "field" should be "password_verify", I believe: ... password => { required => 1, max_len => 20, }, password_verify => { validate_if => 'password', equals => 'password', }, }; ...
This is the section of code which allows a field value without field key to be included in the array: ... ### double check which field_vals have been used so far ### add any remaining field_vals from the order ### this is necessary for items that weren't in group fields or group order my %found = map {$_->{'field'} => 1} @$fields; foreach my $field (@field_keys) { next if $found{$field}; my $field_val = $group_val->{$field}; die "Found a nonhashref value on field $field" if ! UNIVERSAL::isa($field_val, 'HASH'); push @$fields, $field_val; } ... An earlier block adds missing keys: if (ref $field_val && ! $field_val->{'field'}) { $field_val = { %$field_val, 'field' => $field }; # copy the values to add the key } push @fields, $field_val;