# this is the sub that creates the select menu sub elementSelect { my($self,$nm)=@_; # unique keys are data/sql, default # I use data key to create static select menus # sql key to create dynamic menus from tables my $data_array; my $row; my $multiple="no"; my $select=undef; if($self->{ELEMENTS}->{$nm}->{data}){ $data_array=$self->{ELEMENTS}->{$nm}->{data}; }elsif($self->{ELEMENTS}->{$nm}->{sql}){ my $sql=$db->prepare($self->{ELEMENTS}->{$nm}->{sql}); $sql=$db->execute(); while($row=$sql->fetchrow_arrayref){ $data_array->[$row->[0]]=$row->[1]; } } $multiple="yes" if defined $self->{ELEMENTS}->{$nm}->{attributes}->{multiple}; $select=""; return $select; } ##################################################### # DATA VALIDATION FUNCTIONS # this is where i have the problem, the checkRequired sub # should be compatible with both single values and lists in # case of multiple selects ###################################################### sub checkRequired { my($self,$nm)=@_; my $o=""; if(is_array($self->{POST}->param($nm))){ # check for multiple select if(empty($self->{POST}->param($nm))){ # check the array has any values in it # maybe if(self->{POST}->param($nm))??? push @{$self->{ERRORS}},"Please enter ".$self->{ELEMENTS}->{$nm}->{message}."!"; }else{ $o=$self->{POST}->param($nm); } }else{ # value is scalar if($self->{POST}->param($nm) eq ""){ push @{$self->{ERRORS}},"Please enter ".$self->{ELEMENTS}->{$nm}->{message}."!"; }else{ $o=$self->{POST}->param($nm); } } return $o; }