[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] repeating form fields



> I think you've got the right idea, you just missed that a subform isn't
> required, but the restrictions are required if any part of the subform
> is completed.  (D::FV allows this, but not within the _regexp parameters
> that would make it easy).

What are you using for input to $validator->validate?
It sounds like you're using $query->Vars, but you can instead
validate each subform independently, skipping a subform if all
its parameters are empty.

That is, if all fields are indexed by subform number:

my $data = $q->Vars;
foreach my $num (0..$max_subforms) {
      my $subform_params;
      my $subform_contains_data;
      foreach (@required_fields) {
            $subform_params->{$_} = $data->{$_$num};
            $subform_contains_data++ if $data->{$_$num};
      }
      next unless $subform_contains_data;
      $validator->validate($subform_params, 'profile');
}

-- Mike F.




---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.