TheStone gives me a better option
the select is working, but the checkbox isnīt
here is a copy,
Hi,
They'll be added in the next release. For now, you should create two
global templates called 'create_select' and create_checkbox', take a look
at the script below:
- create_select:
sub {
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
return if (lc $cols->{$col}->{'form_type'} ne 'select');
my $values;
my $selected = $tags->{home}->{cgi}->{$col};
my $form_values = $cols->{$col}->{'form_values'};
my $form_names = $cols->{$col}->{'form_names'};
if ($form_values and $form_names and ($#$form_values == $#$form_names)) {
for my $i (0..$#$form_values) {
exists $values->{@$form_values[$i]} or $values->{@$form_values
[$i]} = @$form_names[$i];
}
}
else {
$values = $cols->{$col}->{values};
}
return $tags->{home}->{disp}->select ( {
name => $col,
values => $values,
value => $selected,
blank => 0,
});
}
- create_checkbox:
sub {
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
return if (lc $cols->{$col}->{'form_type'} ne 'checkbox');
my $selected = $tags->{home}->{cgi}->{$col};
my $values = $cols->{$col}->{'form_values'};
my $names = $cols->{$col}->{'form_names'};
return $tags->{home}->{disp}->checkbox( {
name => $col,
values => $values,
value => $selected,
blank => 0 });
}
And then you put <%create_select('field_name')%>, <%create_checkbox%> into
your template file.
Hope that helps,
TheStone.</< body>
the select is working, but the checkbox isnīt
here is a copy,
Hi,
They'll be added in the next release. For now, you should create two
global templates called 'create_select' and create_checkbox', take a look
at the script below:
- create_select:
sub {
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
return if (lc $cols->{$col}->{'form_type'} ne 'select');
my $values;
my $selected = $tags->{home}->{cgi}->{$col};
my $form_values = $cols->{$col}->{'form_values'};
my $form_names = $cols->{$col}->{'form_names'};
if ($form_values and $form_names and ($#$form_values == $#$form_names)) {
for my $i (0..$#$form_values) {
exists $values->{@$form_values[$i]} or $values->{@$form_values
[$i]} = @$form_names[$i];
}
}
else {
$values = $cols->{$col}->{values};
}
return $tags->{home}->{disp}->select ( {
name => $col,
values => $values,
value => $selected,
blank => 0,
});
}
- create_checkbox:
sub {
my $col = shift;
my $tags = GT::Template->tags;
my $cols = $tags->{home}->{db}->cols;
return if (lc $cols->{$col}->{'form_type'} ne 'checkbox');
my $selected = $tags->{home}->{cgi}->{$col};
my $values = $cols->{$col}->{'form_values'};
my $names = $cols->{$col}->{'form_names'};
return $tags->{home}->{disp}->checkbox( {
name => $col,
values => $values,
value => $selected,
blank => 0 });
}
And then you put <%create_select('field_name')%>, <%create_checkbox%> into
your template file.
Hope that helps,
TheStone.</< body>