Hi Charly,
You can use 'view_checked' template global below to determine which boxes have been checked:
sub {
my ($col, $val) = @_;
($col) or return;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
($cols->{$col}->{form_type} =~ /checkbox/i ) or return;
my $f_values = $cols->{$col}->{form_values};
my $f_names = $cols->{$col}->{form_names};
my @values = split(/\n/, $val);
my @output;
foreach my $i (0..$#$f_names) {
my $checked = 0;
foreach my $v (@values) {
if ( $v eq $f_names->[$i] ) {
$checked = 1;
last;
}
}
push @output, { name => $f_values->[$i], value => $f_names->[$i], checked => $checked };
}
return { "loop_$col" => \@output };
}
Now, you can call it within your modify_form
<%view_checked('Pictures', $Pictures)%>
<%loop loop_Pictures%>
<input type="checkbox" name="Pictures" value="<%value%>" <%if checked%>checked<%endif%>><%Name%><br>
<%endif%>
Hope that helps.
TheStone.
B.
You can use 'view_checked' template global below to determine which boxes have been checked:
sub {
my ($col, $val) = @_;
($col) or return;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
($cols->{$col}->{form_type} =~ /checkbox/i ) or return;
my $f_values = $cols->{$col}->{form_values};
my $f_names = $cols->{$col}->{form_names};
my @values = split(/\n/, $val);
my @output;
foreach my $i (0..$#$f_names) {
my $checked = 0;
foreach my $v (@values) {
if ( $v eq $f_names->[$i] ) {
$checked = 1;
last;
}
}
push @output, { name => $f_values->[$i], value => $f_names->[$i], checked => $checked };
}
return { "loop_$col" => \@output };
}
Now, you can call it within your modify_form
<%view_checked('Pictures', $Pictures)%>
<%loop loop_Pictures%>
<input type="checkbox" name="Pictures" value="<%value%>" <%if checked%>checked<%endif%>><%Name%><br>
<%endif%>
Hope that helps.
TheStone.
B.