I recently noticed another challenge processing form variables with
multiple values, which is that you can't use normal validation techniques
to require that at least one of the inputs is filled out. Maybe an answer
is obvious to the rest of you, but it took me a little thinking to come
up with one. The following lines are added at the end of the validate
sub quoted below, and check at time of validation of the last element in
the list to see if any values have been squirreled away.
if (! $id and $value == @things) {
die "need a param_name"
unless (keys %{$ctxt->{Foo}})[0];
}
Does anyone have a more elegant way to solve this problem?
On Fri, 17 Oct 2003 10:24:52 -0500, [EMAIL PROTECTED] said:
> To generate the checkboxes with proper values & labels:
>
> foreach (@things) {
> $id++;
> <f:checkbox name="foo">
> <f:value><xsp:expr>$_->get_name</xsp:expr></f:value>
> <f:index><xsp:expr>$id</xsp:expr></f:index>
> </f:checkbox>
>
> the sub that handles the checkboxes:
>
> sub validate_foo {
> my ($ctxt, $value, $id) = @_;
> if ($value and $id) {
> $ctxt->{Foo}{$value}++;
> }
> }
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]