I've looked through the manual and I'm still
scratching my head.
In my handler I'm populating an array of hashes from
the database like this:
while( (my $feature_code) = $sth->fetchrow ) {
push @features, { feature_code => $feature_code,
feature_name => $feature_name,
feature_author => $feature_author,
feature_img_src =>
$feature_img_src,
feature_syndicate =>
$feature_syndicate };
}
In my template, I have another array of hashes that
I'm using to display the check boxes:
[%
comics => [
{ id => 1, code => 'tmntf', name='9 to 5' },
{ id => 2, code => 'ad', name='Adam@Home' },
{ id => 3, code => 'tmani', name='Animal Crackers'
},
{ id => 4, code => 'tmann', name='Annie' },
{ id => 5, code => 'ba', name='Baldo' },
{ id => 6, code => 'be', name='Baldo en
Español' },
{ id => 7, code => 'bi', name='The Big Picture' },
{ id => 8, code => 'bt', name='Big Top' },
{ id => 9, code => 'bz', name='Bizarro' },
{ id => 10, code => 'bo', name='Boondocks' },
]
%]
In the template, I want to display check boxes and
have the boxed be "checked" if the feature code exists
in one of the feature hashes. With Perl, I'd normally
use the hash "exists" function.
I know I can loop through my feature array:
[% FOREACH feature = features %]
[% feature.feature_code %]
[% END %]
But how do I check if a comic code "exists" in my
feature hash?
[% FOREACH comic = comics.nsort('id') -%]
[% IF comic.code exists in feature???..... %]
[%# Make box checked %]
[% ELSE %]
[%# Else leave box unchecked %]
[% END %]
[% END %]
So essentially if I have this:
push @features, { feature_code => 'ad',.....
and
comics => [
{ id => 2, code => 'ad', name='Adam@Home' },...
I want to display a checked box for Adam@Home.
Thanks...
__________________________________________________
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
http://sbc.yahoo.com